From a7c87315647ee0fa5f41f6d0ef295dd0d5b48fe0 Mon Sep 17 00:00:00 2001 From: evanreichard <30810613+evanreichard@users.noreply.github.com> Date: Sun, 12 Dec 2021 17:57:44 -0500 Subject: [PATCH] [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'. --- Extensions/UserScript/Return Youtube Dislike.user.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Extensions/UserScript/Return Youtube Dislike.user.js b/Extensions/UserScript/Return Youtube Dislike.user.js index a790a1c..e15c4f7 100644 --- a/Extensions/UserScript/Return Youtube Dislike.user.js +++ b/Extensions/UserScript/Return Youtube Dislike.user.js @@ -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,