|
@@ -5,10 +5,12 @@ const config = {
|
|
|
coloredThumbs: false,
|
|
|
coloredBar: false,
|
|
|
colorTheme: "classic",
|
|
|
- numberDisplayFormat: 'compactShort',
|
|
|
+ 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: '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none" opacity=".87"/><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm4.3 14.3c-.39.39-1.02.39-1.41 0L12 13.41 9.11 16.3c-.39.39-1.02.39-1.41 0-.39-.39-.39-1.02 0-1.41L10.59 12 7.7 9.11c-.39-.39-.39-1.02 0-1.41.39-.39 1.02-.39 1.41 0L12 10.59l2.89-2.89c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41z"/></svg>',
|
|
|
+ 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:
|
|
|
+ '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none" opacity=".87"/><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm4.3 14.3c-.39.39-1.02.39-1.41 0L12 13.41 9.11 16.3c-.39.39-1.02.39-1.41 0-.39-.39-.39-1.02 0-1.41L10.59 12 7.7 9.11c-.39-.39-.39-1.02 0-1.41.39-.39 1.02-.39 1.41 0L12 10.59l2.89-2.89c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41z"/></svg>',
|
|
|
|
|
|
links: {
|
|
|
website: "https://returnyoutubedislike.com",
|
|
@@ -16,67 +18,57 @@ const config = {
|
|
|
discord: "https://discord.gg/mYnESY4Md5",
|
|
|
donate: "https://returnyoutubedislike.com/donate",
|
|
|
faq: "https://returnyoutubedislike.com/faq",
|
|
|
- help: "https://returnyoutubedislike.com/help"
|
|
|
+ help: "https://returnyoutubedislike.com/help",
|
|
|
},
|
|
|
};
|
|
|
|
|
|
/* Change language */
|
|
|
-function localizeHtmlPage()
|
|
|
-{
|
|
|
- //Localize by replacing __MSG_***__ meta tags
|
|
|
- var objects = document.getElementsByTagName('html');
|
|
|
- for (var j = 0; j < objects.length; j++)
|
|
|
- {
|
|
|
- var obj = objects[j];
|
|
|
-
|
|
|
- var valStrH = obj.innerHTML.toString();
|
|
|
- var valNewH = valStrH.replace(/__MSG_(\w+)__/g, function(match, v1)
|
|
|
- {
|
|
|
- return v1 ? chrome.i18n.getMessage(v1) : "";
|
|
|
- });
|
|
|
-
|
|
|
- if(valNewH != valStrH)
|
|
|
- {
|
|
|
- obj.innerHTML = valNewH;
|
|
|
- }
|
|
|
+function localizeHtmlPage() {
|
|
|
+ //Localize by replacing __MSG_***__ meta tags
|
|
|
+ var objects = document.getElementsByTagName("html");
|
|
|
+ for (var j = 0; j < objects.length; j++) {
|
|
|
+ var obj = objects[j];
|
|
|
+
|
|
|
+ var valStrH = obj.innerHTML.toString();
|
|
|
+ var valNewH = valStrH.replace(/__MSG_(\w+)__/g, function (match, v1) {
|
|
|
+ return v1 ? chrome.i18n.getMessage(v1) : "";
|
|
|
+ });
|
|
|
+
|
|
|
+ if (valNewH != valStrH) {
|
|
|
+ obj.innerHTML = valNewH;
|
|
|
}
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
localizeHtmlPage();
|
|
|
|
|
|
/* Links */
|
|
|
-createLink(config.links.website,"link_website")
|
|
|
-createLink(config.links.github,"link_github")
|
|
|
-createLink(config.links.discord,"link_discord")
|
|
|
-createLink(config.links.faq,"link_faq")
|
|
|
-createLink(config.links.donate,"link_donate")
|
|
|
-createLink(config.links.help,"link_help")
|
|
|
-
|
|
|
-function createLink(url,id) {
|
|
|
- document.getElementById(id).addEventListener("click",()=>{
|
|
|
- chrome.tabs.create({ url: url})
|
|
|
- })
|
|
|
+createLink(config.links.website, "link_website");
|
|
|
+createLink(config.links.github, "link_github");
|
|
|
+createLink(config.links.discord, "link_discord");
|
|
|
+createLink(config.links.faq, "link_faq");
|
|
|
+createLink(config.links.donate, "link_donate");
|
|
|
+createLink(config.links.help, "link_help");
|
|
|
+
|
|
|
+function createLink(url, id) {
|
|
|
+ document.getElementById(id).addEventListener("click", () => {
|
|
|
+ chrome.tabs.create({ url: url });
|
|
|
+ });
|
|
|
}
|
|
|
document
|
|
|
.getElementById("disable_vote_submission")
|
|
|
.addEventListener("click", (ev) => {
|
|
|
chrome.storage.sync.set({ disableVoteSubmission: ev.target.checked });
|
|
|
});
|
|
|
-document
|
|
|
- .getElementById("colored_thumbs")
|
|
|
- .addEventListener("click", (ev) => {
|
|
|
- chrome.storage.sync.set({ coloredThumbs: ev.target.checked });
|
|
|
- });
|
|
|
-document
|
|
|
- .getElementById("colored_bar")
|
|
|
- .addEventListener("click", (ev) => {
|
|
|
- chrome.storage.sync.set({ coloredBar: ev.target.checked });
|
|
|
- });
|
|
|
-document
|
|
|
- .getElementById("color_theme")
|
|
|
- .addEventListener("click", (ev) => {
|
|
|
- chrome.storage.sync.set({ colorTheme: ev.target.value });
|
|
|
- });
|
|
|
+document.getElementById("colored_thumbs").addEventListener("click", (ev) => {
|
|
|
+ chrome.storage.sync.set({ coloredThumbs: ev.target.checked });
|
|
|
+});
|
|
|
+document.getElementById("colored_bar").addEventListener("click", (ev) => {
|
|
|
+ chrome.storage.sync.set({ coloredBar: ev.target.checked });
|
|
|
+});
|
|
|
+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 });
|
|
@@ -120,7 +112,7 @@ function initConfig() {
|
|
|
|
|
|
function initializeVersionNumber() {
|
|
|
const version = chrome.runtime.getManifest().version;
|
|
|
- document.getElementById('ext-version').innerHTML = 'v' + version;
|
|
|
+ document.getElementById("ext-version").innerHTML = "v" + version;
|
|
|
|
|
|
fetch(
|
|
|
"https://raw.githubusercontent.com/Anarios/return-youtube-dislike/main/Extensions/combined/manifest-chrome.json"
|
|
@@ -128,12 +120,12 @@ function initializeVersionNumber() {
|
|
|
.then((response) => response.json())
|
|
|
.then((json) => {
|
|
|
if (version !== json.version) {
|
|
|
- document.getElementById('ext-update').innerHTML = chrome.i18n.getMessage("textUpdate") +' v' + json.version;
|
|
|
- document.getElementById('ext-update').style.padding = '.25rem .5rem';
|
|
|
+ document.getElementById("ext-update").innerHTML =
|
|
|
+ chrome.i18n.getMessage("textUpdate") + " v" + json.version;
|
|
|
+ document.getElementById("ext-update").style.padding = ".25rem .5rem";
|
|
|
}
|
|
|
});
|
|
|
// .catch(console.error);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
function initializeDisableVoteSubmission() {
|
|
@@ -142,7 +134,6 @@ function initializeDisableVoteSubmission() {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
function initializeColoredThumbs() {
|
|
|
chrome.storage.sync.get(["coloredThumbs"], (res) => {
|
|
|
handleColoredThumbsChangeEvent(res.coloredThumbs);
|
|
@@ -159,7 +150,8 @@ function initializeColorTheme() {
|
|
|
chrome.storage.sync.get(["colorTheme"], (res) => {
|
|
|
handleColorThemeChangeEvent(res.colorTheme);
|
|
|
});
|
|
|
-
|
|
|
+}
|
|
|
+
|
|
|
function initializeNumberDisplayRoundDown() {
|
|
|
chrome.storage.sync.get(["numberDisplayRoundDown"], (res) => {
|
|
|
handleNumberDisplayRoundDownChangeEvent(res.numberDisplayRoundDown);
|
|
@@ -180,12 +172,12 @@ function updateNumberDisplayFormatContent(roundDown) {
|
|
|
} else {
|
|
|
testValue = 123456;
|
|
|
}
|
|
|
- document.getElementById('number_format_compactShort').innerHTML =
|
|
|
- getNumberFormatter('compactShort').format(testValue);
|
|
|
- document.getElementById('number_format_compactLong').innerHTML =
|
|
|
- getNumberFormatter('compactLong').format(testValue);
|
|
|
- document.getElementById('number_format_standard').innerHTML =
|
|
|
- getNumberFormatter('standard').format(testValue);
|
|
|
+ document.getElementById("number_format_compactShort").innerHTML =
|
|
|
+ getNumberFormatter("compactShort").format(testValue);
|
|
|
+ document.getElementById("number_format_compactLong").innerHTML =
|
|
|
+ getNumberFormatter("compactLong").format(testValue);
|
|
|
+ document.getElementById("number_format_standard").innerHTML =
|
|
|
+ getNumberFormatter("standard").format(testValue);
|
|
|
}
|
|
|
|
|
|
chrome.storage.onChanged.addListener(storageChangeHandler);
|
|
@@ -197,19 +189,14 @@ function storageChangeHandler(changes, area) {
|
|
|
);
|
|
|
}
|
|
|
if (changes.coloredThumbs !== undefined) {
|
|
|
- handleColoredThumbsChangeEvent(
|
|
|
- changes.coloredThumbs.newValue
|
|
|
- );
|
|
|
+ handleColoredThumbsChangeEvent(changes.coloredThumbs.newValue);
|
|
|
}
|
|
|
if (changes.coloredBar !== undefined) {
|
|
|
- handleColoredBarChangeEvent(
|
|
|
- changes.coloredBar.newValue
|
|
|
- );
|
|
|
+ handleColoredBarChangeEvent(changes.coloredBar.newValue);
|
|
|
}
|
|
|
if (changes.colorTheme !== undefined) {
|
|
|
- handleColorThemeChangeEvent(
|
|
|
- changes.colorTheme.newValue
|
|
|
- );
|
|
|
+ handleColorThemeChangeEvent(changes.colorTheme.newValue);
|
|
|
+ }
|
|
|
if (changes.numberDisplayRoundDown !== undefined) {
|
|
|
handleNumberDisplayRoundDownChangeEvent(
|
|
|
changes.numberDisplayRoundDown.newValue
|
|
@@ -225,7 +212,6 @@ function handleDisableVoteSubmissionChangeEvent(value) {
|
|
|
document.getElementById("disable_vote_submission").checked = value;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
function handleColoredThumbsChangeEvent(value) {
|
|
|
config.coloredThumbs = value;
|
|
|
document.getElementById("colored_thumbs").checked = value;
|
|
@@ -245,8 +231,11 @@ function handleColorThemeChangeEvent(value) {
|
|
|
}
|
|
|
|
|
|
function updateColorThemePreviewContent(themeName) {
|
|
|
- document.getElementById("color_theme_example_like").style.backgroundColor = getColorFromTheme(themeName, true);
|
|
|
- document.getElementById("color_theme_example_dislike").style.backgroundColor = getColorFromTheme(themeName, false);
|
|
|
+ document.getElementById("color_theme_example_like").style.backgroundColor =
|
|
|
+ getColorFromTheme(themeName, true);
|
|
|
+ document.getElementById("color_theme_example_dislike").style.backgroundColor =
|
|
|
+ getColorFromTheme(themeName, false);
|
|
|
+}
|
|
|
function handleNumberDisplayRoundDownChangeEvent(value) {
|
|
|
config.numberDisplayRoundDown = value;
|
|
|
document.getElementById("number_round_down").checked = value;
|
|
@@ -262,20 +251,20 @@ function handleNumberDisplayFormatChangeEvent(value) {
|
|
|
function getNumberFormatter(optionSelect) {
|
|
|
let formatterNotation;
|
|
|
let formatterCompactDisplay;
|
|
|
-
|
|
|
+
|
|
|
switch (optionSelect) {
|
|
|
- case 'compactLong':
|
|
|
- formatterNotation = 'compact';
|
|
|
- formatterCompactDisplay = 'long';
|
|
|
+ case "compactLong":
|
|
|
+ formatterNotation = "compact";
|
|
|
+ formatterCompactDisplay = "long";
|
|
|
break;
|
|
|
- case 'standard':
|
|
|
- formatterNotation = 'standard';
|
|
|
- formatterCompactDisplay = 'short';
|
|
|
+ case "standard":
|
|
|
+ formatterNotation = "standard";
|
|
|
+ formatterCompactDisplay = "short";
|
|
|
break;
|
|
|
- case 'compactShort':
|
|
|
+ case "compactShort":
|
|
|
default:
|
|
|
- formatterNotation = 'compact';
|
|
|
- formatterCompactDisplay = 'short';
|
|
|
+ formatterNotation = "compact";
|
|
|
+ formatterCompactDisplay = "short";
|
|
|
}
|
|
|
const formatter = Intl.NumberFormat(
|
|
|
document.documentElement.lang || userLocales || navigator.language,
|
|
@@ -307,37 +296,34 @@ function getNumberFormatter(optionSelect) {
|
|
|
}
|
|
|
})();
|
|
|
|
|
|
-
|
|
|
function getColorFromTheme(colorTheme, voteIsLike) {
|
|
|
let colorString;
|
|
|
- switch(colorTheme) {
|
|
|
- case 'accessible':
|
|
|
+ switch (colorTheme) {
|
|
|
+ case "accessible":
|
|
|
if (voteIsLike === true) {
|
|
|
- colorString = 'dodgerblue';
|
|
|
+ colorString = "dodgerblue";
|
|
|
} else {
|
|
|
- colorString = 'gold';
|
|
|
+ colorString = "gold";
|
|
|
}
|
|
|
break;
|
|
|
- case 'neon':
|
|
|
+ case "neon":
|
|
|
if (voteIsLike === true) {
|
|
|
- colorString = 'aqua';
|
|
|
+ colorString = "aqua";
|
|
|
} else {
|
|
|
- colorString = 'magenta';
|
|
|
+ colorString = "magenta";
|
|
|
}
|
|
|
break;
|
|
|
- case 'classic':
|
|
|
+ case "classic":
|
|
|
default:
|
|
|
if (voteIsLike === true) {
|
|
|
- colorString = 'lime';
|
|
|
+ colorString = "lime";
|
|
|
} else {
|
|
|
- colorString = 'red';
|
|
|
+ colorString = "red";
|
|
|
}
|
|
|
}
|
|
|
return colorString;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/* popup-script.js
|
|
|
document.querySelector('#login')
|
|
|
.addEventListener('click', function () {
|