Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Anarios/return-youtube-dislike.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Extensions/combined/src/state.js')
-rw-r--r--Extensions/combined/src/state.js36
1 files changed, 33 insertions, 3 deletions
diff --git a/Extensions/combined/src/state.js b/Extensions/combined/src/state.js
index 7160903..ec2125a 100644
--- a/Extensions/combined/src/state.js
+++ b/Extensions/combined/src/state.js
@@ -23,6 +23,8 @@ let extConfig = {
colorTheme: "classic",
numberDisplayFormat: "compactShort",
numberDisplayRoundDown: true,
+ showTooltipPercentage: false,
+ tooltipPercentageMode: "dash_like",
numberDisplayReformatLikes: false,
};
@@ -40,6 +42,10 @@ function isShorts() {
return location.pathname.startsWith("/shorts");
}
+function isNewDesign() {
+ return document.getElementById("comment-teaser") !== null;
+}
+
let mutationObserver = new Object();
if (isShorts() && mutationObserver.exists !== true) {
@@ -151,10 +157,10 @@ 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;
+ return false;
}
let likesStr = getLikeButton()
- .querySelector("button")
+ .querySelector("yt-formatted-string#text")
.getAttribute("aria-label")
.replace(/\D/g, "");
return likesStr.length > 0 ? parseInt(likesStr) : false;
@@ -200,7 +206,8 @@ function processResponse(response, storedData) {
getDislikeButton().style.color = getColorFromTheme(false);
}
}
- createStarRating(response.rating, isMobile());
+ //Temporary disabling this - it breaks all places where getButtons()[1] is used
+ // createStarRating(response.rating, isMobile());
}
// Tells the user if the API is down
@@ -254,6 +261,8 @@ function initExtConfig() {
initializeColorTheme();
initializeNumberDisplayFormat();
initializeNumberDisplayRoundDown();
+ initializeTooltipPercentage();
+ initializeTooltipPercentageMode();
initializeNumberDisplayReformatLikes();
}
@@ -317,6 +326,26 @@ function initializeNumberDisplayFormat() {
});
}
+function initializeTooltipPercentage() {
+ getBrowser().storage.sync.get(["showTooltipPercentage"], (res) => {
+ if (res.showTooltipPercentage === undefined) {
+ getBrowser().storage.sync.set({ showTooltipPercentage: false });
+ } else {
+ extConfig.showTooltipPercentage = res.showTooltipPercentage;
+ }
+ });
+}
+
+function initializeTooltipPercentageMode() {
+ getBrowser().storage.sync.get(["tooltipPercentageMode"], (res) => {
+ if (res.tooltipPercentageMode === undefined) {
+ getBrowser().storage.sync.set({ tooltipPercentageMode: "dash_like" });
+ } else {
+ extConfig.tooltipPercentageMode = res.tooltipPercentageMode;
+ }
+ });
+}
+
function initializeNumberDisplayReformatLikes() {
getBrowser().storage.sync.get(["numberDisplayReformatLikes"], (res) => {
if (res.numberDisplayReformatLikes === undefined) {
@@ -332,6 +361,7 @@ export {
isShorts,
isVideoDisliked,
isVideoLiked,
+ isNewDesign,
getState,
setState,
setInitialState,