mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-24 07:13:02 +01:00
Implement feature #211
This commit is contained in:
1 parent
0db29c557f
commit
50466e2a2b
5 files changed
+125
-3
No files matched your search
@@ -13,7 +13,7 @@ function createRateBar(likes, dislikes) {
|
||||
const widthPercent =
|
||||
likes + dislikes > 0 ? (likes / (likes + dislikes)) * 100 : 50;
|
||||
|
||||
var likePercentage = Math.round(widthPercent.toFixed(1));
|
||||
var likePercentage = parseFloat(widthPercent.toFixed(1));
|
||||
const dislikePercentage = (100 - likePercentage).toLocaleString();
|
||||
likePercentage = likePercentage.toLocaleString();
|
||||
const tooltipPercentageDisplayModes = {
|
||||
@@ -25,7 +25,10 @@ function createRateBar(likes, dislikes) {
|
||||
"only_dislike": `${dislikePercentage}%`
|
||||
};
|
||||
|
||||
const tooltipOption = "both";
|
||||
var tooltipOption = "classic";
|
||||
if (extConfig.showTooltipPercentage) {
|
||||
tooltipOption = extConfig.tooltipPercentageMode;
|
||||
};
|
||||
|
||||
|
||||
if (!rateBar && !isMobile()) {
|
||||
|
||||
@@ -24,6 +24,8 @@ let extConfig = {
|
||||
colorTheme: "classic",
|
||||
numberDisplayFormat: "compactShort",
|
||||
numberDisplayRoundDown: true,
|
||||
showTooltipPercentage: false,
|
||||
tooltipPercentageMode: "dash_like",
|
||||
};
|
||||
|
||||
let storedData = {
|
||||
@@ -171,6 +173,8 @@ function initExtConfig() {
|
||||
initializeColorTheme();
|
||||
initializeNumberDisplayFormat();
|
||||
initializeNumberDisplayRoundDown();
|
||||
initializeTooltipPercentage();
|
||||
initializeTooltipPercentageMode();
|
||||
}
|
||||
|
||||
function initializeDisableVoteSubmission() {
|
||||
@@ -233,6 +237,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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
isMobile,
|
||||
isShorts,
|
||||
|
||||
Reference in new issue
Block a user