mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-28 17:07:55 +01:00
Merge branch 'main' into ColorizedButtonsAndBar-New
This commit is contained in:
29 files changed
+741
-93
No files matched your search
@@ -19,14 +19,43 @@ function numberFormat(numberState) {
|
||||
?.getAttribute("href")
|
||||
)?.searchParams?.get("locale");
|
||||
} catch {}
|
||||
|
||||
let numberDisplay;
|
||||
if (extConfig.numberDisplayRoundDown === false) {
|
||||
numberDisplay = numberState;
|
||||
} else {
|
||||
numberDisplay = roundDown(numberState);
|
||||
}
|
||||
return getNumberFormatter(extConfig.numberDisplayFormat).format(numberDisplay);
|
||||
}
|
||||
|
||||
function getNumberFormatter(optionSelect) {
|
||||
let formatterNotation;
|
||||
let formatterCompactDisplay;
|
||||
|
||||
switch(optionSelect) {
|
||||
case 'compactLong':
|
||||
formatterNotation = 'compact';
|
||||
formatterCompactDisplay = 'long';
|
||||
break;
|
||||
case 'standard':
|
||||
formatterNotation = 'standard';
|
||||
formatterCompactDisplay = 'short';
|
||||
break;
|
||||
case 'compactShort':
|
||||
default:
|
||||
formatterNotation = 'compact';
|
||||
formatterCompactDisplay = 'short';
|
||||
}
|
||||
|
||||
const formatter = Intl.NumberFormat(
|
||||
document.documentElement.lang || userLocales || navigator.language,
|
||||
{
|
||||
notation: "compact",
|
||||
notation: formatterNotation,
|
||||
compactDisplay: formatterCompactDisplay,
|
||||
}
|
||||
);
|
||||
|
||||
return formatter.format(roundDown(numberState));
|
||||
return formatter;
|
||||
}
|
||||
|
||||
function getBrowser() {
|
||||
@@ -49,10 +78,25 @@ function getVideoId(url) {
|
||||
if (pathname.startsWith("/clip")) {
|
||||
return document.querySelector("meta[itemprop='videoId']").content;
|
||||
} else {
|
||||
if (pathname.startsWith("/shorts")) {
|
||||
return pathname.substr(8);
|
||||
}
|
||||
return urlObject.searchParams.get("v");
|
||||
}
|
||||
}
|
||||
|
||||
function isInViewport(element) {
|
||||
const rect = element.getBoundingClientRect();
|
||||
const height = innerHeight || document.documentElement.clientHeight;
|
||||
const width = innerWidth || document.documentElement.clientWidth;
|
||||
return (
|
||||
rect.top >= 0 &&
|
||||
rect.left >= 0 &&
|
||||
rect.bottom <= height &&
|
||||
rect.right <= width
|
||||
);
|
||||
}
|
||||
|
||||
function isVideoLoaded() {
|
||||
const videoId = getVideoId(window.location.href);
|
||||
return (
|
||||
@@ -71,6 +115,7 @@ function cLog(message, writer) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getColorFromTheme(voteIsLike) {
|
||||
let colorString;
|
||||
switch(extConfig.colorTheme) {
|
||||
@@ -106,4 +151,5 @@ export {
|
||||
isVideoLoaded,
|
||||
cLog,
|
||||
getColorFromTheme,
|
||||
}
|
||||
}
|
||||
export { numberFormat, getBrowser, getVideoId, isInViewport, isVideoLoaded, cLog }
|
||||
Reference in new issue
Block a user