Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Extra currencies for selected region #4

Open
DawEdhel opened this issue Jan 8, 2022 · 20 comments
Open

[Feature request] Extra currencies for selected region #4

DawEdhel opened this issue Jan 8, 2022 · 20 comments

Comments

@DawEdhel
Copy link

DawEdhel commented Jan 8, 2022

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.

@kevinfiol
Copy link
Owner

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.

@DawEdhel
Copy link
Author

DawEdhel commented Jan 10, 2022

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

@kevinfiol
Copy link
Owner

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.

@kevinfiol
Copy link
Owner

kevinfiol commented Jan 27, 2022

@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:
image

Since I am a US user, selecting UK + GBP will display the GBP price alongside my native US price.

@DawEdhel
Copy link
Author

DawEdhel commented Jan 27, 2022

@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:

  • 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.
  • Different languages provide different money formats. As for some of them, extra currency price's text gets appeared in-between initial price and its currency sign.
  • As an appendix to the previous bullet point, what about putting extra price with its crossed-out, undiscounted price (from the GOG API) to the right of the primary one to be neatly aligned, similar to how only single price gets displayed?
  • Sometimes there is currently lower deal on another shop, which prevents showing what is the actual price on GOG. Can you add "Current Lowest Price on GOG" in-between there?
  • What about renaming bottom labels to "ITAD region" and "GOG local currency" to avoid possible confusions?
  • How about adding an option to collapse/expand ITAD section at the bottom or even the whole price panel (which your latest screenshot does showcase wholly)? There might be some background watchers who will say thanks :)

@kevinfiol
Copy link
Owner

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:
image

@DawEdhel
Copy link
Author

Well, I'm rather an user in CIS region, and that is how it does look to me.
Screenshot 2022-01-28 090624

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.

@kevinfiol
Copy link
Owner

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}

@DawEdhel
Copy link
Author

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.

@kevinfiol
Copy link
Owner

kevinfiol commented Feb 11, 2022

Thanks, I am using productcardData. BTW, you can test the WIP version here: [redacted]

@DawEdhel
Copy link
Author

DawEdhel commented Feb 12, 2022

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.

@kevinfiol
Copy link
Owner

kevinfiol commented Feb 12, 2022

@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

@DawEdhel
Copy link
Author

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.

@kevinfiol
Copy link
Owner

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?

image

Perhaps you can take a screenshot of this issue. I am not able to replicate it.

@DawEdhel
Copy link
Author

DawEdhel commented Feb 16, 2022

I mean GOG personal settings located within its footer, like in this screenshot I provided earlier.

Screenshot 2022-01-28 090624

What happens is after some changing manipulation within your script's section

  1. preferred USD currency gets replaced by RUS one, which happens pretty almost every time
  2. English language gets replaced by Russian one. As a result, whole UI localization changes accordingly, so it's too noticeable.

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.

2022-02-16.10-08-20.mp4

@kevinfiol
Copy link
Owner

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.

image

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.

@DawEdhel
Copy link
Author

DawEdhel commented Feb 17, 2022

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.

@kevinfiol
Copy link
Owner

@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
Copy link
Author

@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.

@kevinfiol
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants