mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-29 09:27:54 +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) {
|
function numberFormat(numberState) {
|
||||||
let localeURL = Array.from(document.querySelectorAll("head > link[rel='search']"))
|
let userLocales;
|
||||||
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
|
try {
|
||||||
?.getAttribute("href");
|
userLocales = new URL(
|
||||||
|
Array.from(document.querySelectorAll("head > link[rel='search']"))
|
||||||
const userLocales = localeURL ? new URL(localeURL)?.searchParams?.get("locale") : document.body.lang;
|
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
|
||||||
|
?.getAttribute("href")
|
||||||
|
)?.searchParams?.get("locale");
|
||||||
|
} catch {}
|
||||||
const formatter = Intl.NumberFormat(
|
const formatter = Intl.NumberFormat(
|
||||||
document.documentElement.lang || userLocales || navigator.language,
|
document.documentElement.lang || userLocales || navigator.language,
|
||||||
{
|
{
|
||||||
notation: "compact",
|
notation: "compact",
|
||||||
minimumFractionDigits: 1,
|
|
||||||
maximumFractionDigits: 1,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return formatter.format(roundDown(numberState)).replace(/\.0|,0/, "");
|
return formatter.format(roundDown(numberState));
|
||||||
}
|
}
|
||||||
|
|
||||||
function setEventListeners(evt) {
|
function setEventListeners(evt) {
|
||||||
|
|||||||
Reference in new issue
Block a user