mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-22 06:13:07 +01:00
[fix] YouTube Mobile Locale URL Doesn't Exist
On m.youtube.com, the locale URL doesn't exist. This will throw an invalid URL (passes undefined to the URL constructor). On quick glance it doesn't appear that there's a good alternative on mobile, so I just fallback to 'en'.
This commit is contained in:
1 parent
a1ca95231d
commit
a7c8731564
1 file changed
+5
-5
@@ -354,11 +354,11 @@ function roundDown(num) {
|
||||
}
|
||||
|
||||
function numberFormat(numberState) {
|
||||
const userLocales = new URL(
|
||||
Array.from(document.querySelectorAll("head > link[rel='search']"))
|
||||
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
|
||||
?.getAttribute("href")
|
||||
)?.searchParams?.get("locale");
|
||||
let localeURL = Array.from(document.querySelectorAll("head > link[rel='search']"))
|
||||
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
|
||||
?.getAttribute("href");
|
||||
|
||||
const userLocales = localeURL ? new URL(localeURL)?.searchParams?.get("locale") : 'en';
|
||||
|
||||
const formatter = Intl.NumberFormat(
|
||||
document.documentElement.lang || userLocales,
|
||||
|
||||
Reference in new issue
Block a user