Yahoo API disabled -> patch using fixer.io instead
Closed this issue · 2 comments
Since Yahoo disabled it's online service for fetching exchange rates etc. I looked for some replacement and I came up with this solution.
In the function fetchCurrencyData
replace the call to the Yahoo API with the following code:
onload: responseDetails => {
var rate = JSON.parse(responseDetails.responseText).rates[currencyTo];
GM_log("Rate: " + rate);
GM_setValue(CURRENCY_RATE + coin, rate);
GM_setValue(LAST_RUN + coin, todayString);
callback();
IMPORTANT:
You have to call that function once since the extension caches the rates for 1 day!
I did it by adding the call to the end and disabled it afterwards:
fetchCurrencyData(currencyFrom, function() {
rate = GM_getValue(CURRENCY_RATE + currencyFrom);
convertCurrency(document);
registerMutationObserver();
});
I got the idea from another Amazon Price extension:
https://github.com/FurkanKambay/AmazonPrice/
Perhaps you can join forces since I like your implementation a lot more since it converts all prices instead of only the product price.
I've already switched to fixer.io locally, as part of upgrading to the new Web Extensions-based Greasemonkey.
I'm going to reject the PR, and after I commit my updates to the script, will close this issue.
I uploaded the new changes.
The change to fixer.io is at https://github.com/salty-horse/gm-scripts/blob/b404f2a1c82dccd86ab9aae3154d33b2143d5c2c/amazonLocalCurrency.user.js
Beyond this commit, the script now uses the Greasemonkey 4 API which is incompatible with previous versions.