mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-26 08:13:00 +01:00
RoundDown option removed
This commit is contained in:
1 parent
752edcc27f
commit
8e376f6142
8 files changed
+17
-103
No files matched your search
@@ -6,7 +6,6 @@ const config = {
|
||||
coloredBar: false,
|
||||
colorTheme: "classic",
|
||||
numberDisplayFormat: "compactShort",
|
||||
numberDisplayRoundDown: true,
|
||||
showAdvancedMessage:
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><rect fill="none" height="24" width="24"/><path d="M19.5,12c0-0.23-0.01-0.45-0.03-0.68l1.86-1.41c0.4-0.3,0.51-0.86,0.26-1.3l-1.87-3.23c-0.25-0.44-0.79-0.62-1.25-0.42 l-2.15,0.91c-0.37-0.26-0.76-0.49-1.17-0.68l-0.29-2.31C14.8,2.38,14.37,2,13.87,2h-3.73C9.63,2,9.2,2.38,9.14,2.88L8.85,5.19 c-0.41,0.19-0.8,0.42-1.17,0.68L5.53,4.96c-0.46-0.2-1-0.02-1.25,0.42L2.41,8.62c-0.25,0.44-0.14,0.99,0.26,1.3l1.86,1.41 C4.51,11.55,4.5,11.77,4.5,12s0.01,0.45,0.03,0.68l-1.86,1.41c-0.4,0.3-0.51,0.86-0.26,1.3l1.87,3.23c0.25,0.44,0.79,0.62,1.25,0.42 l2.15-0.91c0.37,0.26,0.76,0.49,1.17,0.68l0.29,2.31C9.2,21.62,9.63,22,10.13,22h3.73c0.5,0,0.93-0.38,0.99-0.88l0.29-2.31 c0.41-0.19,0.8-0.42,1.17-0.68l2.15,0.91c0.46,0.2,1,0.02,1.25-0.42l1.87-3.23c0.25-0.44,0.14-0.99-0.26-1.3l-1.86-1.41 C19.49,12.45,19.5,12.23,19.5,12z M12.04,15.5c-1.93,0-3.5-1.57-3.5-3.5s1.57-3.5,3.5-3.5s3.5,1.57,3.5,3.5S13.97,15.5,12.04,15.5z"/></svg>',
|
||||
hideAdvancedMessage:
|
||||
|
||||
@@ -29,11 +29,12 @@
|
||||
"js": ["ryd.content-script.js"]
|
||||
}
|
||||
]
|
||||
// ,
|
||||
// "browser_specific_settings": {
|
||||
// "gecko": {
|
||||
// "id": "addon@example.com",
|
||||
// "strict_min_version": "42.0"
|
||||
// }
|
||||
// }
|
||||
// uncomment this section for local storage to work in firefox locally
|
||||
,
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
"id": "addon@example.com",
|
||||
"strict_min_version": "42.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,21 +104,15 @@
|
||||
|
||||
<label class="switch" data-hover="Stop counting your likes and dislikes">
|
||||
<input type="checkbox" id="disable_vote_submission" />
|
||||
<span class="slider" />
|
||||
<span class="slider"></span>
|
||||
<span class="switchLabel" title="__MSG_textSettings__">
|
||||
__MSG_textSettings__
|
||||
</span>
|
||||
</label>
|
||||
<br />
|
||||
<label class="switch" data-hover="__MSG_roundNumbersHover__">
|
||||
<input type="checkbox" id="number_round_down" />
|
||||
<span class="slider" />
|
||||
<span class="switchLabel">__MSG_roundNumbers__</span>
|
||||
</label>
|
||||
<br />
|
||||
<label class="switch" data-hover="__MSG_reformatLikesHover__">
|
||||
<input type="checkbox" id="number_reformat_likes" />
|
||||
<span class="slider" />
|
||||
<span class="slider"></span>
|
||||
<span class="switchLabel">__MSG_reformatLikes__</span>
|
||||
</label>
|
||||
<br />
|
||||
@@ -134,13 +128,13 @@
|
||||
<div class="custom-select">
|
||||
<label class="switch" data-hover="__MSG_colorizeRatioHover__">
|
||||
<input type="checkbox" id="colored_bar" />
|
||||
<span class="slider" />
|
||||
<span class="slider"></span>
|
||||
<span class="switchLabel">__MSG_colorizeRatio__</span>
|
||||
</label>
|
||||
</div>
|
||||
<label class="switch" data-hover="__MSG_colorizeThumbsHover__">
|
||||
<input type="checkbox" id="colored_thumbs" />
|
||||
<span class="slider" />
|
||||
<span class="slider"></span>
|
||||
<span class="switchLabel">__MSG_colorizeThumbs__</span>
|
||||
</label>
|
||||
<br />
|
||||
@@ -184,7 +178,7 @@
|
||||
data-hover="Display percentage in like/dislike bar tooltip."
|
||||
>
|
||||
<input type="checkbox" id="show_tooltip_percentage" />
|
||||
<span class="slider" />
|
||||
<span class="slider"></span>
|
||||
<span class="switchLabel">Percentage in like/dislike bar tooltip.</span>
|
||||
</label>
|
||||
<div class="custom-select">
|
||||
|
||||
@@ -8,7 +8,6 @@ const config = {
|
||||
coloredBar: false,
|
||||
colorTheme: "classic",
|
||||
numberDisplayFormat: "compactShort",
|
||||
numberDisplayRoundDown: true,
|
||||
showTooltipPercentage: false,
|
||||
tooltipPercentageMode: "dash_like",
|
||||
numberDisplayReformatLikes: false,
|
||||
@@ -81,10 +80,6 @@ document.getElementById("color_theme").addEventListener("click", (ev) => {
|
||||
chrome.storage.sync.set({ colorTheme: ev.target.value });
|
||||
});
|
||||
|
||||
document.getElementById("number_round_down").addEventListener("click", (ev) => {
|
||||
chrome.storage.sync.set({ numberDisplayRoundDown: ev.target.checked });
|
||||
updateNumberDisplayFormatContent(ev.target.checked);
|
||||
});
|
||||
|
||||
document.getElementById("number_format").addEventListener("change", (ev) => {
|
||||
chrome.storage.sync.set({ numberDisplayFormat: ev.target.value });
|
||||
@@ -135,7 +130,6 @@ function initConfig() {
|
||||
initializeColoredBar();
|
||||
initializeColorTheme();
|
||||
initializeNumberDisplayFormat();
|
||||
initializeNumberDisplayRoundDown();
|
||||
initializeTooltipPercentage();
|
||||
initializeTooltipPercentageMode();
|
||||
initializeNumberDisplayReformatLikes();
|
||||
@@ -203,11 +197,6 @@ function initializeColorTheme() {
|
||||
});
|
||||
}
|
||||
|
||||
function initializeNumberDisplayRoundDown() {
|
||||
chrome.storage.sync.get(["numberDisplayRoundDown"], (res) => {
|
||||
handleNumberDisplayRoundDownChangeEvent(res.numberDisplayRoundDown);
|
||||
});
|
||||
}
|
||||
|
||||
function initializeTooltipPercentage() {
|
||||
chrome.storage.sync.get(["showTooltipPercentage"], (res) => {
|
||||
@@ -228,13 +217,8 @@ function initializeNumberDisplayFormat() {
|
||||
updateNumberDisplayFormatContent();
|
||||
}
|
||||
|
||||
function updateNumberDisplayFormatContent(roundDown) {
|
||||
let testValue;
|
||||
if (roundDown) {
|
||||
testValue = 123000;
|
||||
} else {
|
||||
testValue = 123456;
|
||||
}
|
||||
function updateNumberDisplayFormatContent() {
|
||||
let testValue = 123456;
|
||||
document.getElementById("number_format_compactShort").innerHTML =
|
||||
getNumberFormatter("compactShort").format(testValue);
|
||||
document.getElementById("number_format_compactLong").innerHTML =
|
||||
@@ -266,11 +250,6 @@ function storageChangeHandler(changes, area) {
|
||||
if (changes.colorTheme !== undefined) {
|
||||
handleColorThemeChangeEvent(changes.colorTheme.newValue);
|
||||
}
|
||||
if (changes.numberDisplayRoundDown !== undefined) {
|
||||
handleNumberDisplayRoundDownChangeEvent(
|
||||
changes.numberDisplayRoundDown.newValue
|
||||
);
|
||||
}
|
||||
if (changes.numberDisplayFormat !== undefined) {
|
||||
handleNumberDisplayFormatChangeEvent(changes.numberDisplayFormat.newValue);
|
||||
}
|
||||
@@ -319,10 +298,7 @@ function updateColorThemePreviewContent(themeName) {
|
||||
getColorFromTheme(themeName, false);
|
||||
}
|
||||
|
||||
function handleNumberDisplayRoundDownChangeEvent(value) {
|
||||
config.numberDisplayRoundDown = value;
|
||||
document.getElementById("number_round_down").checked = value;
|
||||
}
|
||||
|
||||
|
||||
function handleNumberDisplayFormatChangeEvent(value) {
|
||||
config.numberDisplayFormat = value;
|
||||
|
||||
@@ -10,7 +10,6 @@ let extConfig = {
|
||||
coloredBar: false,
|
||||
colorTheme: "classic", // classic, accessible, neon
|
||||
numberDisplayFormat: "compactShort", // compactShort, compactLong, standard
|
||||
numberDisplayRoundDown: true, // locale 'de' shows exact numbers by default
|
||||
numberDisplayReformatLikes: false, // use existing (native) likes number
|
||||
};
|
||||
|
||||
@@ -266,11 +265,6 @@ function storageChangeHandler(changes, area) {
|
||||
if (changes.colorTheme !== undefined) {
|
||||
handleColorThemeChangeEvent(changes.colorTheme.newValue);
|
||||
}
|
||||
if (changes.numberDisplayRoundDown !== undefined) {
|
||||
handleNumberDisplayRoundDownChangeEvent(
|
||||
changes.numberDisplayRoundDown.newValue
|
||||
);
|
||||
}
|
||||
if (changes.numberDisplayFormat !== undefined) {
|
||||
handleNumberDisplayFormatChangeEvent(changes.numberDisplayFormat.newValue);
|
||||
}
|
||||
@@ -315,10 +309,6 @@ function handleTooltipPercentageModeChangeEvent(value) {
|
||||
extConfig.tooltipPercentageMode = value;
|
||||
}
|
||||
|
||||
function handleNumberDisplayRoundDownChangeEvent(value) {
|
||||
extConfig.numberDisplayRoundDown = value;
|
||||
}
|
||||
|
||||
function changeIcon(iconName) {
|
||||
if (api.action !== undefined)
|
||||
api.action.setIcon({ path: "/icons/" + iconName });
|
||||
@@ -354,7 +344,6 @@ function initExtConfig() {
|
||||
initializeColoredBar();
|
||||
initializeColorTheme();
|
||||
initializeNumberDisplayFormat();
|
||||
initializeNumberDisplayRoundDown();
|
||||
initializeNumberDisplayReformatLikes();
|
||||
initializeTooltipPercentage();
|
||||
initializeTooltipPercentageMode();
|
||||
@@ -381,15 +370,6 @@ function initializeColoredThumbs() {
|
||||
});
|
||||
}
|
||||
|
||||
function initializeNumberDisplayRoundDown() {
|
||||
api.storage.sync.get(["numberDisplayRoundDown"], (res) => {
|
||||
if (res.numberDisplayRoundDown === undefined) {
|
||||
api.storage.sync.set({ numberDisplayRoundDown: true });
|
||||
} else {
|
||||
extConfig.numberDisplayRoundDown = res.numberDisplayRoundDown;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initializeColoredBar() {
|
||||
api.storage.sync.get(["coloredBar"], (res) => {
|
||||
|
||||
@@ -108,12 +108,6 @@ function storageChangeHandler(changes, area) {
|
||||
if (changes.colorTheme !== undefined) {
|
||||
handleColorThemeChangeEvent(changes.colorTheme.newValue);
|
||||
}
|
||||
|
||||
if (changes.numberDisplayRoundDown !== undefined) {
|
||||
handleNumberDisplayRoundDownChangeEvent(
|
||||
changes.numberDisplayRoundDown.newValue
|
||||
);
|
||||
}
|
||||
if (changes.numberDisplayFormat !== undefined) {
|
||||
handleNumberDisplayFormatChangeEvent(changes.numberDisplayFormat.newValue);
|
||||
}
|
||||
@@ -145,10 +139,6 @@ function handleNumberDisplayFormatChangeEvent(value) {
|
||||
extConfig.numberDisplayFormat = value;
|
||||
}
|
||||
|
||||
function handleNumberDisplayRoundDownChangeEvent(value) {
|
||||
extConfig.numberDisplayRoundDown = value;
|
||||
}
|
||||
|
||||
function handleNumberDisplayReformatLikesChangeEvent(value) {
|
||||
extConfig.numberDisplayReformatLikes = value;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ let extConfig = {
|
||||
coloredBar: false,
|
||||
colorTheme: "classic",
|
||||
numberDisplayFormat: "compactShort",
|
||||
numberDisplayRoundDown: true,
|
||||
showTooltipPercentage: false,
|
||||
tooltipPercentageMode: "dash_like",
|
||||
numberDisplayReformatLikes: false,
|
||||
@@ -260,7 +259,6 @@ function initExtConfig() {
|
||||
initializeColoredBar();
|
||||
initializeColorTheme();
|
||||
initializeNumberDisplayFormat();
|
||||
initializeNumberDisplayRoundDown();
|
||||
initializeTooltipPercentage();
|
||||
initializeTooltipPercentageMode();
|
||||
initializeNumberDisplayReformatLikes();
|
||||
@@ -296,16 +294,6 @@ function initializeColoredBar() {
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
import { extConfig } from "./state";
|
||||
|
||||
function roundDown(num) {
|
||||
if (num < 1000) return num;
|
||||
const int = Math.floor(Math.log10(num) - 2);
|
||||
const decimal = int + (int % 3 ? 1 : 0);
|
||||
const value = Math.floor(num / 10 ** decimal);
|
||||
return value * 10 ** decimal;
|
||||
}
|
||||
|
||||
function numberFormat(numberState) {
|
||||
let numberDisplay;
|
||||
if (extConfig.numberDisplayRoundDown === false) {
|
||||
numberDisplay = numberState;
|
||||
} else {
|
||||
numberDisplay = roundDown(numberState);
|
||||
}
|
||||
return getNumberFormatter(extConfig.numberDisplayFormat).format(
|
||||
numberDisplay
|
||||
numberState
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user