Open DawEdhel opened 2 years ago
Hey, thanks for adding this feature request.
I see what you're saying. It seems that in order to implement this, the plugin would need to call another external API to handle the conversions. Otherwise, the conversions would be made using static rates that may go out of date over time.
I noticed a few packages on npm that may be able to help with this, but I will take a deep dive hopefully by the end of the week.
Not sure if you're aware of this but I've found this GOG API method, which provides all available currencies and their prices for specific country. https://api.gog.com/products/{product_id}/prices?countryCode={country_code}
Example: https://api.gog.com/products/2093619782/prices?countryCode=DE
Hey @DawEdhel sorry for the wait.
Just want to give a heads up that I started implementing this today. I hope to have a release out by the end of this week.
@DawEdhel Please see and test out this WIP version: https://gist.github.com/kevinfiol/fa89240425d7db6ffacc1b3ac72292b3/raw/2243ed40d1dcfe5d50ccafba316cd91c6f2089c8/enhanced-gog.user.js
One limitation I realized while working on this is that I do not have the price conversions for the data provided by IsThereAnyDeal, only the latest prices available by GOG for a given title. Given that, I chose to instead add a feature where if the selected currency is different from the user's official GOG given currency, the different price is displayed alongside the current sale price.
Personally, I'm not super happy with the result, but let me know if this is useful to you.
EDIT: See a screenshot example:
Since I am a US user, selecting UK + GBP will display the GBP price alongside my native US price.
@kevinfiol I've played around with WIP version, and it does look like what I wanted, but with small caveat: that extra price is filled by ITAD region's price, not GOG API currency's one, so I'm getting discrepancies here.
Also I'll mention various findings of bugs and helpful additions:
that extra price is filled by ITAD region's price, not GOG API currency's one, so I'm getting discrepancies here.
I may have fundamentally misunderstood your initial request. I now see what you intended, and this actually may be far simpler to implement than what I had done! 😆
Just to confirm, as a user in the "DE" region, what does your footer look like? For me as a US user, mine appears as such:
Well, I'm rather an user in CIS region, and that is how it does look to me.
The main problem, that started it all initially, is my country is not supported by ITAD. Thus I'm having discrepancies between ITAD nearest RU region's prices and GOG local ones.
Revisiting this again and leaving a note for myself:
To implement this, I need to find a way to grab the current user's GOG Country Code from the page. This way, I can fetch the appropriate available prices from https://api.gog.com/products/{product_id}/prices?countryCode={country_code}
To implement this, I need to find a way to grab the current user's GOG Country Code from the page. This way, I can fetch the appropriate available prices from https://api.gog.com/products/{product_id}/prices?countryCode={country_code}
Found local JSON 'window.gogMicroservices.menu' and 'window.productcardData', both of which contain 'country' field. Not sure about their reliability overall, yet personally for me they are showcasing the right country code.
Thanks, I am using productcardData. BTW, you can test the WIP version here: [redacted]
BTW, you can test the WIP version here: https://github.com/kevinfiol/enhanced-gog/raw/feature/currencies/bin/enhanced-gog.user.js
Not sure, but I'm not getting anything new after the current stable 1.3.0, as there is neither the crossed-out extra currency price, nor the select list to choose as well. Am I missing something or is it too soon to test?
Btw, can you change the @ script name to something else, like enhanced-gog-beta? My current extension always tries to update the stable release, instead of creating a new entry.
@DawEdhel Sorry about that. Here is the updated version: https://gist.github.com/kevinfiol/e79dac59d567146ac1e3aacd21f1e382/raw/cc99fce024d2ad85a5e6657e09b1107cef9187a5/enhanced-gog-beta.user.js
You can also grab it directly from the feature branch while I'm pushing changes: https://github.com/kevinfiol/enhanced-gog/tree/feature/currencies/bin
Updated and tested - so far so good as discussed, except this mentioned part still change GOG site's params.
- Changing region and/or currency (and with page refreshing afterwards?) affect GOG selected language/currency somewhat randomly. I don't think that's desirable behaviour.
Sometimes it even happens on its own without any modification and/or even on different, non-game GOG pages. It looks like either something gets them reset to default values, or the script modifies them directly anyhow.
If you need help debugging, you can tell me, where to look at supposedly, and, just in case, how to do it properly, as I'm somewhat barely familiar with both JS and consoles.
Changing region and/or currency (and with page refreshing afterwards?) affect GOG selected language/currency somewhat randomly. I don't think that's desirable behaviour.
I'm not sure what is being affected here. You mean this select box is being affected randomly?
Perhaps you can take a screenshot of this issue. I am not able to replicate it.
I mean GOG personal settings located within its footer, like in this screenshot I provided earlier.
What happens is after some changing manipulation within your script's section
It might be GOG doing when these currency/language get somewhat corrupted, so it does resetting them to most fitting default values closest to your country, which in my case is Russia. And you probably can't replicate it due to being as a US user, you will always get ENG/USD values, both of which you have already selected as preferable, so you possibly can't distinct if they're set by either your selection or site's resetting. Can you try at least change local language and see if it will drop back to English?
As for currencies to replicate, I guess, using VPN on new account for some country with several rates might help.
Edit: decided to make a clip of the whole process on my side, see for yourself. Redrawing happens after hitting the F5 button.
That is truly strange. Just a heads up, the "Language" and "Currency" settings in the Footer are outside of enhanced-gog's control. Those are set via cookie by GOG's backend, so enhanced-gog
has zero effect on them. So it looks like something GOG.com is doing.
You are right in that I am only able to select USD since I am located in the US. To confirm, I did, however, test by switching my language and seeing if it would drop back to English
, which, it did but only upon navigating away from the page (I am also logged into my GOG account).
I even tried setting my language specifically at https://www.gog.com/account/settings/personal , and even then it would switch back to English. Notice the discrepancy between the Footer language and the Locale Language Dropdown in this screenshot.
My guess is that t his is a bug on GOG's side unfortunately, where they are reading your user agent and forcing a language/currency.
By any chance, are you using Firefox or any cookie-blocking extensions? I would say to be lenient to cookie settings specifically on gog.com and see if that makes a difference (maybe allow 3rd party cookies?). I'll also investigate this myself.
That is truly strange. Just a heads up, the "Language" and "Currency" settings in the Footer are outside of enhanced-gog's control. Those are set via cookie by GOG's backend, so
enhanced-gog
has zero effect on them. So it looks like something GOG.com is doing.
Yet I still don't understand then, why GOG suddenly only does that behaviour when modifying script's params, if these are only internal to the script and shouldn't be visible to GOG. Maybe something still gets affected indirectly by the modification that GOG doesn't like.
By any chance, are you using Firefox or any cookie-blocking extensions?
Usually I'm using Chrome while always logged in, and that's where is the clip from. Potential extensions that could affect and I'm currently using: ublock origin + tampermonkey.
I'd actually tested on Firefox as well while incognito and unlogged, and I couldn't reproduce it. So either it's login info or cookies that you've mentioned.
Edit: turned off ublock temporarily - still the same behaviour.
@DawEdhel Are you still getting this behavior from GOG? I seem to experience it regardless if I have enhanced-gog installed or not. Wondering if this is also still an issue for you.
@DawEdhel Are you still getting this behavior from GOG? I seem to experience it regardless if I have enhanced-gog installed or not. Wondering if this is also still an issue for you.
Do you mean the stable version or the beta one? Never had the problem with the former one, yet using the latter one at the moment still provides the same buggy behaviour as mentioned before.
Btw I've done same actions on stable release, and everything stays the same in terms of currency/language/etc on GOG side.
@DawEdhel Are you still getting this behavior from GOG? I seem to experience it regardless if I have enhanced-gog installed or not. Wondering if this is also still an issue for you.
Do you mean the stable version or the beta one? Never had the problem with the former one, yet using the latter one at the moment still provides the same buggy behaviour as mentioned before.
Btw I've done same actions on stable release, and everything stays the same in terms of currency/language/etc on GOG side.
I see. I wasn't aware that the issue didn't exist on the stable release. Very strange; as I mentioned before, enhanced-gog doesn't modify or add any cookies, so I don't see how it can affect this. I may need to look into specifically what cookies affect the GOG region -- perhaps I can override it.
I would like to have extra currencies for selected region as another comparing baselines. Currently, as I understand, selected region can only provide its forced currency, but as I have to use another one, it's required for me to do own conversion computations.
So overall, my request is to add the option of having along with current region's forced currency number another ones, selected opt-in by an user. For example, if currently selected region is US and its returned value is "5$", then after this request's implementation I select additionally EU currency, instead I will get "5$ (4€)" (interface's showcase may vary).
As I don't know ITAD API, but the way I see, to implement this request it requires at least to have selected region's individual conversion rates.