Merge pull request #281 from evanreichard/patch-2

[fix] YouTube Mobile Locale URL Doesn't Exist
This commit is contained in:
Dmitrii Selivanov authored and GitHub committed 2021-12-15 01:23:13 +03:00
commit 78c7563410
1 file changed
+6 -6
@@ -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,