sereneblue / chameleon

WebExtension port of Random Agent Spoofer
https://sereneblue.github.io/chameleon
GNU General Public License v3.0
488 stars 51 forks source link

timezone spoof for date.parse throws NaN #583

Open Thorin-Oakenpants opened 1 month ago

Thorin-Oakenpants commented 1 month ago

STR

example

https://github.com/arkenfox/TZP/blob/43c20737b4aeeeef4f2b119c89087a2223c7485e/js/region.js#L873-L901

sereneblue commented 1 month ago

Thanks for reporting @Thorin-Oakenpants.

It seems this is caused when a date pre-modern timezones is used. I have to do some further review to see what's the best way to handle those dates.

Thorin-Oakenpants commented 4 weeks ago

there's a lot more going on - e.g. even when not specifying spoof language, you modify the resolved locale for Intl.DateTimeFormat to en-US - at odds with all the rest (if you are not en-US of course)

IANAE on your code or webextensions, but you can simply pass undefined as the locale and timezone as the timeZone - for all the Intl and for toLocaleString and toLocaleDateString

edit: and when spoofing as e.g. Russian, nothing changes with navigator.language(s) to match, and locales are left alone: I'm not sure what your strategy is here, it's all so paradoxical :)