diff options
author | Dmitrii Selivanov <selivano.d@gmail.com> | 2021-12-15 01:23:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-15 01:23:13 +0300 |
commit | 78c7563410d236957c664ac22e803145d0e0749d (patch) | |
tree | 9530bea28f1ad17ab55d7a3fd8f3def720180f28 /Extensions | |
parent | 82f14fcc83ce994eb03f985c9842644bfc14fcfc (diff) | |
parent | 15215558ae24e956124bc3b4ca7cc0b9853499d9 (diff) |
Merge pull request #281 from evanreichard/patch-2
[fix] YouTube Mobile Locale URL Doesn't Exist
Diffstat (limited to 'Extensions')
-rw-r--r-- | Extensions/UserScript/Return Youtube Dislike.user.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Extensions/UserScript/Return Youtube Dislike.user.js b/Extensions/UserScript/Return Youtube Dislike.user.js index a790a1c..2cdad78 100644 --- a/Extensions/UserScript/Return Youtube Dislike.user.js +++ b/Extensions/UserScript/Return Youtube Dislike.user.js @@ -354,14 +354,14 @@ 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") : document.body.lang; const formatter = Intl.NumberFormat( - document.documentElement.lang || userLocales, + document.documentElement.lang || userLocales || navigator.language, { notation: "compact", minimumFractionDigits: 1, |