Merge branch 'main' into ColorizedButtonsAndBar-New

This commit is contained in:
Dmitrii Selivanov authored and GitHub committed 2022-03-20 23:24:08 +03:00
commit f218443b4c
29 files changed
+741 -93

No files matched your search

+33 -1
View File
@@ -22,6 +22,8 @@ let extConfig = {
coloredThumbs: false,
coloredBar: false,
colorTheme: "classic",
numberDisplayFormat: 'compactShort',
numberDisplayRoundDown: true,
};
let storedData = {
@@ -36,6 +38,10 @@ function isMobile() {
return location.hostname == "m.youtube.com";
}
function isShorts() {
return location.pathname.startsWith("/shorts")
}
function isVideoLiked() {
if (isMobile()) {
return (
@@ -81,7 +87,7 @@ function setDislikes(dislikesCount) {
}
getButtons().children[1].querySelector("#text").innerText = dislikesCount;
} else {
cLog("likes count diabled by creator");
cLog("likes count disabled by creator");
if (isMobile()) {
getButtons().children[1].querySelector(
".button-renderer-text"
@@ -94,6 +100,11 @@ function setDislikes(dislikesCount) {
}
function getLikeCountFromButton() {
if(isShorts()) {
//Youtube Shorts don't work with this query. It's not nessecary; we can skip it and still see the results.
//It should be possible to fix this function, but it's not critical to showing the dislike count.
return 0;
}
let likesStr = getLikeButton()
.querySelector("button")
.getAttribute("aria-label")
@@ -158,6 +169,8 @@ function initExtConfig() {
initializeColoredThumbs();
initializeColoredBar();
initializeColorTheme();
initializeNumberDisplayFormat();
initializeNumberDisplayRoundDown();
}
function initializeDisableVoteSubmission() {
@@ -170,6 +183,7 @@ function initializeDisableVoteSubmission() {
});
}
function initializeColoredThumbs() {
getBrowser().storage.sync.get(['coloredThumbs'], (res) => {
if (res.coloredThumbs === undefined) {
@@ -189,9 +203,17 @@ function initializeColoredBar() {
else {
extConfig.coloredBar = res.coloredBar;
}
function initializeNumberDisplayRoundDown() {
getBrowser().storage.sync.get(["numberDisplayRoundDown"], (res) => {
if (res.numberDisplayRoundDown === undefined) {
getBrowser().storage.sync.set({ numberDisplayRoundDown: true });
} else {
extConfig.numberDisplayRoundDown = res.numberDisplayRoundDown;
}
});
}
function initializeColorTheme() {
getBrowser().storage.sync.get(['colorTheme'], (res) => {
if (res.colorTheme === undefined) {
@@ -200,11 +222,21 @@ function initializeColorTheme() {
else {
extConfig.colorTheme = res.colorTheme;
}
}
function initializeNumberDisplayFormat() {
getBrowser().storage.sync.get(['numberDisplayFormat'], (res) => {
if (res.numberDisplayFormat === undefined) {
getBrowser().storage.sync.set({ numberDisplayFormat: 'compactShort' });
}
else {
extConfig.numberDisplayFormat = res.numberDisplayFormat;
}
});
}
export {
isMobile,
isShorts,
isVideoDisliked,
isVideoLiked,
getState,