mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-21 22:03:01 +01:00
Merge pull request #366 from oSumAtrIX/format-dislikes
Format numbers the same way as the extension for the UserScript
This commit is contained in:
1 file changed
+9
-9
@@ -311,22 +311,22 @@ function roundDown(num) {
|
||||
}
|
||||
|
||||
function numberFormat(numberState) {
|
||||
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;
|
||||
|
||||
let userLocales;
|
||||
try {
|
||||
userLocales = new URL(
|
||||
Array.from(document.querySelectorAll("head > link[rel='search']"))
|
||||
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
|
||||
?.getAttribute("href")
|
||||
)?.searchParams?.get("locale");
|
||||
} catch {}
|
||||
const formatter = Intl.NumberFormat(
|
||||
document.documentElement.lang || userLocales || navigator.language,
|
||||
{
|
||||
notation: "compact",
|
||||
minimumFractionDigits: 1,
|
||||
maximumFractionDigits: 1,
|
||||
}
|
||||
);
|
||||
|
||||
return formatter.format(roundDown(numberState)).replace(/\.0|,0/, "");
|
||||
return formatter.format(roundDown(numberState));
|
||||
}
|
||||
|
||||
function setEventListeners(evt) {
|
||||
|
||||
Reference in new issue
Block a user