mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-30 09:57:52 +01:00
Merge branch 'main' into fork/khangquangtran/main
# Conflicts: # CONTRIBUTING.md # CONTRIBUTINGfr.md # CONTRIBUTINGnl.md # CONTRIBUTINGpl.md # CONTRIBUTINGru.md # CONTRIBUTINGtr.md # CONTRIBUTINGuk.md # Docs/FAQ.md # Docs/FAQfr.md # Docs/FAQnl.md # Docs/FAQpl.md # Docs/FAQru.md # Docs/FAQtr.md # Docs/FAQuk.md # Docs/SECURITY-FAQ.md # Docs/SECURITY-FAQfr.md # Docs/SECURITY-FAQnl.md # Docs/SECURITY-FAQpl.md # Docs/SECURITY-FAQru.md # Docs/SECURITY-FAQtr.md # Docs/SECURITY-FAQuk.md # Docs/readme.md # Docs/readmefr.md # Docs/readmenl.md # Docs/readmetr.md # README.md # READMEcn.md # READMEde.md # READMEes.md # READMEfr.md # READMEgr.md # READMEja.md # READMEnl.md # READMEpl.md # READMEru.md # READMEsv.md # READMEtr.md # READMEuk.md # Website/README.md # Website/READMEnl.md # Website/READMEtr.md # Website/layouts/default.vue # Website/nuxt.config.js # Website/pages/links.vue # Website/store/README.md # Website/store/READMEnl.md # Website/store/READMEtr.md
This commit is contained in:
commit
180840a063
166 files changed
+23478
-27574
No files matched your search
@@ -2,7 +2,7 @@
|
||||
// @name Return YouTube Dislike
|
||||
// @namespace https://www.returnyoutubedislike.com/
|
||||
// @homepage https://www.returnyoutubedislike.com/
|
||||
// @version 3.1.3
|
||||
// @version 3.1.5
|
||||
// @encoding utf-8
|
||||
// @description Return of the YouTube Dislike, Based off https://www.returnyoutubedislike.com/
|
||||
// @icon https://github.com/Anarios/return-youtube-dislike/raw/main/Icons/Return%20Youtube%20Dislike%20-%20Transparent.png
|
||||
@@ -28,6 +28,7 @@ const extConfig = {
|
||||
// You may change the following variables to allowed values listed in the corresponding brackets (* means default). Keep the style and keywords intact.
|
||||
showUpdatePopup: false, // [true, false*] Show a popup tab after extension update (See what's new)
|
||||
disableVoteSubmission: false, // [true, false*] Disable like/dislike submission (Stops counting your likes and dislikes)
|
||||
disableLogging: true, // [true*, false] Disable Logging API Response in JavaScript Console.
|
||||
coloredThumbs: false, // [true, false*] Colorize thumbs (Use custom colors for thumb icons)
|
||||
coloredBar: false, // [true, false*] Colorize ratio bar (Use custom colors for ratio bar)
|
||||
colorTheme: "classic", // [classic*, accessible, neon] Color theme (red/green, blue/yellow, pink/cyan)
|
||||
@@ -35,6 +36,7 @@ const extConfig = {
|
||||
numberDisplayRoundDown: true, // [true*, false] Round down numbers (Show rounded down numbers)
|
||||
tooltipPercentageMode: "none", // [none*, dash_like, dash_dislike, both, only_like, only_dislike] Mode of showing percentage in like/dislike bar tooltip.
|
||||
numberDisplayReformatLikes: false, // [true, false*] Re-format like numbers (Make likes and dislikes format consistent)
|
||||
rateBarEnabled: false, // [true, false*] Enables ratio bar under like/dislike buttons
|
||||
// END USER OPTIONS
|
||||
};
|
||||
|
||||
@@ -44,13 +46,16 @@ const NEUTRAL_STATE = "NEUTRAL_STATE";
|
||||
let previousState = 3; //1=LIKED, 2=DISLIKED, 3=NEUTRAL
|
||||
let likesvalue = 0;
|
||||
let dislikesvalue = 0;
|
||||
let preNavigateLikeButton = null;
|
||||
|
||||
let isMobile = location.hostname == "m.youtube.com";
|
||||
let isShorts = () => location.pathname.startsWith("/shorts");
|
||||
let mobileDislikes = 0;
|
||||
function cLog(text, subtext = "") {
|
||||
subtext = subtext.trim() === "" ? "" : `(${subtext})`;
|
||||
console.log(`[Return YouTube Dislikes] ${text} ${subtext}`);
|
||||
if (!extConfig.disableLogging) {
|
||||
subtext = subtext.trim() === "" ? "" : `(${subtext})`;
|
||||
console.log(`[Return YouTube Dislikes] ${text} ${subtext}`);
|
||||
}
|
||||
}
|
||||
|
||||
function isInViewport(element) {
|
||||
@@ -71,9 +76,7 @@ function isInViewport(element) {
|
||||
function getButtons() {
|
||||
if (isShorts()) {
|
||||
let elements = document.querySelectorAll(
|
||||
isMobile
|
||||
? "ytm-like-button-renderer"
|
||||
: "#like-button > ytd-like-button-renderer"
|
||||
isMobile ? "ytm-like-button-renderer" : "#like-button > ytd-like-button-renderer",
|
||||
);
|
||||
for (let element of elements) {
|
||||
if (isInViewport(element)) {
|
||||
@@ -93,23 +96,33 @@ function getButtons() {
|
||||
document.querySelector("ytd-menu-renderer.ytd-video-primary-info-renderer > div")
|
||||
);
|
||||
} else {
|
||||
return document
|
||||
.getElementById("menu-container")
|
||||
?.querySelector("#top-level-buttons-computed");
|
||||
return document.getElementById("menu-container")?.querySelector("#top-level-buttons-computed");
|
||||
}
|
||||
}
|
||||
|
||||
function getDislikeButton() {
|
||||
return getButtons().children[0].tagName ===
|
||||
"YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER"
|
||||
? getButtons().children[0].children[1] === undefined ? document.querySelector("#segmented-dislike-button") : getButtons().children[0].children[1]
|
||||
: getButtons().querySelector("dislike-button-view-model") ?? getButtons().children[1];
|
||||
if (getButtons().children[0].tagName === "YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER") {
|
||||
if (getButtons().children[0].children[1] === undefined) {
|
||||
return document.querySelector("#segmented-dislike-button");
|
||||
} else {
|
||||
return getButtons().children[0].children[1];
|
||||
}
|
||||
} else {
|
||||
if (getButtons().querySelector("segmented-like-dislike-button-view-model")) {
|
||||
const dislikeViewModel = getButtons().querySelector("dislike-button-view-model");
|
||||
if (!dislikeViewModel) cLog("Dislike button wasn't added to DOM yet...");
|
||||
return dislikeViewModel;
|
||||
} else {
|
||||
return getButtons().children[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getLikeButton() {
|
||||
return getButtons().children[0].tagName ===
|
||||
"YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER"
|
||||
? document.querySelector("#segmented-like-button") !== null ? document.querySelector("#segmented-like-button") : getButtons().children[0].children[0]
|
||||
return getButtons().children[0].tagName === "YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER"
|
||||
? document.querySelector("#segmented-like-button") !== null
|
||||
? document.querySelector("#segmented-like-button")
|
||||
: getButtons().children[0].children[0]
|
||||
: getButtons().querySelector("like-button-view-model") ?? getButtons().children[0];
|
||||
}
|
||||
|
||||
@@ -121,79 +134,80 @@ function getLikeTextContainer() {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function getDislikeTextContainer() {
|
||||
const dislikeButton = getDislikeButton();
|
||||
let result =
|
||||
getDislikeButton().querySelector("#text") ??
|
||||
getDislikeButton().getElementsByTagName("yt-formatted-string")[0] ??
|
||||
getDislikeButton().querySelector("span[role='text']")
|
||||
dislikeButton?.querySelector("#text") ??
|
||||
dislikeButton?.getElementsByTagName("yt-formatted-string")[0] ??
|
||||
dislikeButton?.querySelector("span[role='text']");
|
||||
if (result === null) {
|
||||
let textSpan = document.createElement("span");
|
||||
textSpan.id = "text";
|
||||
textSpan.style.marginLeft = "6px";
|
||||
getDislikeButton().querySelector("button").appendChild(textSpan);
|
||||
getDislikeButton().querySelector("button").style.width = "auto";
|
||||
result = getDislikeButton().querySelector("#text");
|
||||
dislikeButton?.querySelector("button").appendChild(textSpan);
|
||||
if (dislikeButton) dislikeButton.querySelector("button").style.width = "auto";
|
||||
result = textSpan;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
let mutationObserver = new Object();
|
||||
|
||||
if (isShorts() && mutationObserver.exists !== true) {
|
||||
cLog("initializing mutation observer");
|
||||
mutationObserver.options = {
|
||||
childList: false,
|
||||
attributes: true,
|
||||
subtree: false,
|
||||
function createObserver(options, callback) {
|
||||
const observerWrapper = new Object();
|
||||
observerWrapper.options = options;
|
||||
observerWrapper.observer = new MutationObserver(callback);
|
||||
observerWrapper.observe = function (element) {
|
||||
this.observer.observe(element, this.options);
|
||||
};
|
||||
mutationObserver.exists = true;
|
||||
mutationObserver.observer = new MutationObserver(function (
|
||||
mutationList,
|
||||
observer
|
||||
) {
|
||||
mutationList.forEach((mutation) => {
|
||||
if (
|
||||
mutation.type === "attributes" &&
|
||||
mutation.target.nodeName === "TP-YT-PAPER-BUTTON" &&
|
||||
mutation.target.id === "button"
|
||||
) {
|
||||
cLog("Short thumb button status changed");
|
||||
if (mutation.target.getAttribute("aria-pressed") === "true") {
|
||||
mutation.target.style.color =
|
||||
mutation.target.parentElement.parentElement.id === "like-button"
|
||||
? getColorFromTheme(true)
|
||||
: getColorFromTheme(false);
|
||||
} else {
|
||||
mutation.target.style.color = "unset";
|
||||
observerWrapper.disconnect = function () {
|
||||
this.observer.disconnect();
|
||||
};
|
||||
return observerWrapper;
|
||||
}
|
||||
|
||||
let shortsObserver = null;
|
||||
|
||||
if (isShorts() && !shortsObserver) {
|
||||
cLog("Initializing shorts mutation observer");
|
||||
shortsObserver = createObserver(
|
||||
{
|
||||
attributes: true,
|
||||
},
|
||||
(mutationList) => {
|
||||
mutationList.forEach((mutation) => {
|
||||
if (
|
||||
mutation.type === "attributes" &&
|
||||
mutation.target.nodeName === "TP-YT-PAPER-BUTTON" &&
|
||||
mutation.target.id === "button"
|
||||
) {
|
||||
cLog("Short thumb button status changed");
|
||||
if (mutation.target.getAttribute("aria-pressed") === "true") {
|
||||
mutation.target.style.color =
|
||||
mutation.target.parentElement.parentElement.id === "like-button"
|
||||
? getColorFromTheme(true)
|
||||
: getColorFromTheme(false);
|
||||
} else {
|
||||
mutation.target.style.color = "unset";
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
cLog(
|
||||
"unexpected mutation observer event: " + mutation.target + mutation.type
|
||||
);
|
||||
});
|
||||
});
|
||||
cLog("Unexpected mutation observer event: " + mutation.target + mutation.type);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function isVideoLiked() {
|
||||
if (isMobile) {
|
||||
return (
|
||||
getLikeButton().querySelector("button").getAttribute("aria-label") ==
|
||||
"true"
|
||||
);
|
||||
return getLikeButton().querySelector("button").getAttribute("aria-label") == "true";
|
||||
}
|
||||
return getLikeButton().classList.contains("style-default-active");
|
||||
}
|
||||
|
||||
function isVideoDisliked() {
|
||||
if (isMobile) {
|
||||
return (
|
||||
getDislikeButton().querySelector("button").getAttribute("aria-label") ==
|
||||
"true"
|
||||
);
|
||||
return getDislikeButton()?.querySelector("button").getAttribute("aria-label") == "true";
|
||||
}
|
||||
return getDislikeButton().classList.contains("style-default-active");
|
||||
return getDislikeButton()?.classList.contains("style-default-active");
|
||||
}
|
||||
|
||||
function isVideoNotLiked() {
|
||||
@@ -207,7 +221,7 @@ function isVideoNotDisliked() {
|
||||
if (isMobile) {
|
||||
return !isVideoDisliked();
|
||||
}
|
||||
return getDislikeButton().classList.contains("style-text");
|
||||
return getDislikeButton()?.classList.contains("style-text");
|
||||
}
|
||||
|
||||
function checkForUserAvatarButton() {
|
||||
@@ -233,8 +247,7 @@ function getState() {
|
||||
|
||||
function setLikes(likesCount) {
|
||||
if (isMobile) {
|
||||
getButtons().children[0].querySelector(".button-renderer-text").innerText =
|
||||
likesCount;
|
||||
getButtons().children[0].querySelector(".button-renderer-text").innerText = likesCount;
|
||||
return;
|
||||
}
|
||||
getLikeTextContainer().innerText = likesCount;
|
||||
@@ -245,8 +258,12 @@ function setDislikes(dislikesCount) {
|
||||
mobileDislikes = dislikesCount;
|
||||
return;
|
||||
}
|
||||
getDislikeTextContainer()?.removeAttribute('is-empty');
|
||||
getDislikeTextContainer().innerText = dislikesCount;
|
||||
|
||||
const _container = getDislikeTextContainer();
|
||||
_container?.removeAttribute("is-empty");
|
||||
if (_container?.innerText !== dislikesCount) {
|
||||
_container.innerText = dislikesCount;
|
||||
}
|
||||
}
|
||||
|
||||
function getLikeCountFromButton() {
|
||||
@@ -256,18 +273,14 @@ function getLikeCountFromButton() {
|
||||
//It should be possible to fix this function, but it's not critical to showing the dislike count.
|
||||
return false;
|
||||
}
|
||||
let likeButton = getLikeButton()
|
||||
.querySelector("yt-formatted-string#text") ??
|
||||
getLikeButton().querySelector("button");
|
||||
let likeButton =
|
||||
getLikeButton().querySelector("yt-formatted-string#text") ?? getLikeButton().querySelector("button");
|
||||
|
||||
let likesStr = likeButton.getAttribute("aria-label")
|
||||
.replace(/\D/g, "");
|
||||
let likesStr = likeButton.getAttribute("aria-label").replace(/\D/g, "");
|
||||
return likesStr.length > 0 ? parseInt(likesStr) : false;
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
(typeof GM_addStyle != "undefined"
|
||||
@@ -290,10 +303,10 @@ function getLikeCountFromButton() {
|
||||
}
|
||||
|
||||
.ryd-tooltip {
|
||||
position: relative;
|
||||
position: absolute;
|
||||
display: block;
|
||||
height: 2px;
|
||||
top: 9px;
|
||||
bottom: -10px;
|
||||
}
|
||||
|
||||
.ryd-tooltip-bar-container {
|
||||
@@ -301,24 +314,28 @@ function getLikeCountFromButton() {
|
||||
height: 2px;
|
||||
position: absolute;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 28px;
|
||||
padding-bottom: 12px;
|
||||
top: -6px;
|
||||
}
|
||||
|
||||
ytd-menu-renderer.ytd-watch-metadata {
|
||||
overflow-y: visible !important;
|
||||
}
|
||||
|
||||
#top-level-buttons-computed {
|
||||
position: relative !important;
|
||||
}
|
||||
`);
|
||||
|
||||
function createRateBar(likes, dislikes) {
|
||||
if (isMobile) {
|
||||
if (isMobile || !extConfig.rateBarEnabled) {
|
||||
return;
|
||||
}
|
||||
let rateBar = document.getElementById("return-youtube-dislike-bar-container");
|
||||
|
||||
const widthPx =
|
||||
getButtons().children[0].clientWidth +
|
||||
getButtons().children[1].clientWidth +
|
||||
8;
|
||||
const widthPx = getLikeButton().clientWidth + (getDislikeButton()?.clientWidth ?? 52);
|
||||
|
||||
const widthPercent =
|
||||
likes + dislikes > 0 ? (likes / (likes + dislikes)) * 100 : 50;
|
||||
const widthPercent = likes + dislikes > 0 ? (likes / (likes + dislikes)) * 100 : 50;
|
||||
|
||||
var likePercentage = parseFloat(widthPercent.toFixed(1));
|
||||
const dislikePercentage = (100 - likePercentage).toLocaleString();
|
||||
@@ -353,7 +370,7 @@ function createRateBar(likes, dislikes) {
|
||||
colorDislikeStyle = "; background-color: " + getColorFromTheme(false);
|
||||
}
|
||||
|
||||
document.getElementById("menu-container").insertAdjacentHTML(
|
||||
getButtons().insertAdjacentHTML(
|
||||
"beforeend",
|
||||
`
|
||||
<div class="ryd-tooltip" style="width: ${widthPx}px">
|
||||
@@ -372,25 +389,18 @@ function createRateBar(likes, dislikes) {
|
||||
<!--css-build:shady-->${tooltipInnerHTML}
|
||||
</tp-yt-paper-tooltip>
|
||||
</div>
|
||||
`
|
||||
`,
|
||||
);
|
||||
let descriptionAndActionsElement = document.getElementById("top-row");
|
||||
descriptionAndActionsElement.style.borderBottom = "1px solid var(--yt-spec-10-percent-layer)";
|
||||
descriptionAndActionsElement.style.paddingBottom = "10px";
|
||||
} else {
|
||||
document.getElementById(
|
||||
"return-youtube-dislike-bar-container"
|
||||
).style.width = widthPx + "px";
|
||||
document.getElementById("return-youtube-dislike-bar").style.width =
|
||||
widthPercent + "%";
|
||||
|
||||
document.querySelector("#ryd-dislike-tooltip > #tooltip").innerHTML =
|
||||
tooltipInnerHTML;
|
||||
document.querySelector(".ryd-tooltip").style.width = widthPx + "px";
|
||||
document.getElementById("return-youtube-dislike-bar").style.width = widthPercent + "%";
|
||||
|
||||
if (extConfig.coloredBar) {
|
||||
document.getElementById(
|
||||
"return-youtube-dislike-bar-container"
|
||||
).style.backgroundColor = getColorFromTheme(false);
|
||||
document.getElementById(
|
||||
"return-youtube-dislike-bar"
|
||||
).style.backgroundColor = getColorFromTheme(true);
|
||||
document.getElementById("return-youtube-dislike-bar-container").style.backgroundColor = getColorFromTheme(false);
|
||||
document.getElementById("return-youtube-dislike-bar").style.backgroundColor = getColorFromTheme(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -399,9 +409,7 @@ function setState() {
|
||||
cLog("Fetching votes...");
|
||||
let statsSet = false;
|
||||
|
||||
fetch(
|
||||
`https://returnyoutubedislikeapi.com/votes?videoId=${getVideoId()}`
|
||||
).then((response) => {
|
||||
fetch(`https://returnyoutubedislikeapi.com/votes?videoId=${getVideoId()}`).then((response) => {
|
||||
response.json().then((json) => {
|
||||
if (json && !("traceId" in response) && !statsSet) {
|
||||
const { dislikes, likes } = json;
|
||||
@@ -417,31 +425,22 @@ function setState() {
|
||||
}
|
||||
createRateBar(likes, dislikes);
|
||||
if (extConfig.coloredThumbs === true) {
|
||||
const dislikeButton = getDislikeButton();
|
||||
if (isShorts()) {
|
||||
// for shorts, leave deactived buttons in default color
|
||||
let shortLikeButton = getLikeButton().querySelector(
|
||||
"tp-yt-paper-button#button"
|
||||
);
|
||||
let shortDislikeButton = getDislikeButton().querySelector(
|
||||
"tp-yt-paper-button#button"
|
||||
);
|
||||
const shortLikeButton = getLikeButton().querySelector("tp-yt-paper-button#button");
|
||||
const shortDislikeButton = dislikeButton?.querySelector("tp-yt-paper-button#button");
|
||||
if (shortLikeButton.getAttribute("aria-pressed") === "true") {
|
||||
shortLikeButton.style.color = getColorFromTheme(true);
|
||||
}
|
||||
if (shortDislikeButton.getAttribute("aria-pressed") === "true") {
|
||||
if (shortDislikeButton && shortDislikeButton.getAttribute("aria-pressed") === "true") {
|
||||
shortDislikeButton.style.color = getColorFromTheme(false);
|
||||
}
|
||||
mutationObserver.observer.observe(
|
||||
shortLikeButton,
|
||||
mutationObserver.options
|
||||
);
|
||||
mutationObserver.observer.observe(
|
||||
shortDislikeButton,
|
||||
mutationObserver.options
|
||||
);
|
||||
shortsObserver.observe(shortLikeButton);
|
||||
shortsObserver.observe(shortDislikeButton);
|
||||
} else {
|
||||
getLikeButton().style.color = getColorFromTheme(true);
|
||||
getDislikeButton().style.color = getColorFromTheme(false);
|
||||
if (dislikeButton) dislikeButton.style.color = getColorFromTheme(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -449,22 +448,25 @@ function setState() {
|
||||
});
|
||||
}
|
||||
|
||||
function updateDOMDislikes() {
|
||||
setDislikes(numberFormat(dislikesvalue));
|
||||
createRateBar(likesvalue, dislikesvalue);
|
||||
}
|
||||
|
||||
function likeClicked() {
|
||||
if (checkForUserAvatarButton() == true) {
|
||||
if (previousState == 1) {
|
||||
likesvalue--;
|
||||
createRateBar(likesvalue, dislikesvalue);
|
||||
setDislikes(numberFormat(dislikesvalue));
|
||||
updateDOMDislikes();
|
||||
previousState = 3;
|
||||
} else if (previousState == 2) {
|
||||
likesvalue++;
|
||||
dislikesvalue--;
|
||||
setDislikes(numberFormat(dislikesvalue));
|
||||
createRateBar(likesvalue, dislikesvalue);
|
||||
updateDOMDislikes();
|
||||
previousState = 1;
|
||||
} else if (previousState == 3) {
|
||||
likesvalue++;
|
||||
createRateBar(likesvalue, dislikesvalue);
|
||||
updateDOMDislikes();
|
||||
previousState = 1;
|
||||
}
|
||||
if (extConfig.numberDisplayReformatLikes === true) {
|
||||
@@ -480,19 +482,16 @@ function dislikeClicked() {
|
||||
if (checkForUserAvatarButton() == true) {
|
||||
if (previousState == 3) {
|
||||
dislikesvalue++;
|
||||
setDislikes(numberFormat(dislikesvalue));
|
||||
createRateBar(likesvalue, dislikesvalue);
|
||||
updateDOMDislikes();
|
||||
previousState = 2;
|
||||
} else if (previousState == 2) {
|
||||
dislikesvalue--;
|
||||
setDislikes(numberFormat(dislikesvalue));
|
||||
createRateBar(likesvalue, dislikesvalue);
|
||||
updateDOMDislikes();
|
||||
previousState = 3;
|
||||
} else if (previousState == 1) {
|
||||
likesvalue--;
|
||||
dislikesvalue++;
|
||||
setDislikes(numberFormat(dislikesvalue));
|
||||
createRateBar(likesvalue, dislikesvalue);
|
||||
updateDOMDislikes();
|
||||
previousState = 2;
|
||||
if (extConfig.numberDisplayReformatLikes === true) {
|
||||
const nativeLikes = getLikeCountFromButton();
|
||||
@@ -512,7 +511,7 @@ function getVideoId() {
|
||||
const urlObject = new URL(window.location.href);
|
||||
const pathname = urlObject.pathname;
|
||||
if (pathname.startsWith("/clip")) {
|
||||
return document.querySelector("meta[itemprop='videoId']").content;
|
||||
return (document.querySelector("meta[itemprop='videoId']") || document.querySelector("meta[itemprop='identifier']")).content;
|
||||
} else {
|
||||
if (pathname.startsWith("/shorts")) {
|
||||
return pathname.slice(8);
|
||||
@@ -528,7 +527,12 @@ function isVideoLoaded() {
|
||||
const videoId = getVideoId();
|
||||
|
||||
return (
|
||||
document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null
|
||||
// desktop: spring 2024 UI
|
||||
document.querySelector(`ytd-watch-grid[video-id='${videoId}']`) !== null ||
|
||||
// desktop: older UI
|
||||
document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null ||
|
||||
// mobile: no video-id attribute
|
||||
document.querySelector('#player[loading="false"]:not([hidden])') !== null
|
||||
);
|
||||
}
|
||||
|
||||
@@ -547,9 +551,7 @@ function numberFormat(numberState) {
|
||||
} else {
|
||||
numberDisplay = roundDown(numberState);
|
||||
}
|
||||
return getNumberFormatter(extConfig.numberDisplayFormat).format(
|
||||
numberDisplay
|
||||
);
|
||||
return getNumberFormatter(extConfig.numberDisplayFormat).format(numberDisplay);
|
||||
}
|
||||
|
||||
function getNumberFormatter(optionSelect) {
|
||||
@@ -563,12 +565,10 @@ function getNumberFormatter(optionSelect) {
|
||||
userLocales = new URL(
|
||||
Array.from(document.querySelectorAll("head > link[rel='search']"))
|
||||
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
|
||||
?.getAttribute("href")
|
||||
?.getAttribute("href"),
|
||||
)?.searchParams?.get("locale");
|
||||
} catch {
|
||||
cLog(
|
||||
"Cannot find browser locale. Use en as default for number formatting."
|
||||
);
|
||||
cLog("Cannot find browser locale. Use en as default for number formatting.");
|
||||
userLocales = "en";
|
||||
}
|
||||
}
|
||||
@@ -625,6 +625,8 @@ function getColorFromTheme(voteIsLike) {
|
||||
return colorString;
|
||||
}
|
||||
|
||||
let smartimationObserver = null;
|
||||
|
||||
function setEventListeners(evt) {
|
||||
let jsInitChecktimer;
|
||||
|
||||
@@ -632,21 +634,46 @@ function setEventListeners(evt) {
|
||||
//console.log();
|
||||
if (isShorts() || (getButtons()?.offsetParent && isVideoLoaded())) {
|
||||
const buttons = getButtons();
|
||||
const dislikeButton = getDislikeButton();
|
||||
|
||||
if (!window.returnDislikeButtonlistenersSet) {
|
||||
if (preNavigateLikeButton !== getLikeButton() && dislikeButton) {
|
||||
cLog("Registering button listeners...");
|
||||
try {
|
||||
getLikeButton().addEventListener("click", likeClicked);
|
||||
getDislikeButton().addEventListener("click", dislikeClicked);
|
||||
dislikeButton?.addEventListener("click", dislikeClicked);
|
||||
getLikeButton().addEventListener("touchstart", likeClicked);
|
||||
getDislikeButton().addEventListener("touchstart", dislikeClicked);
|
||||
dislikeButton?.addEventListener("touchstart", dislikeClicked);
|
||||
dislikeButton?.addEventListener("focusin", updateDOMDislikes);
|
||||
dislikeButton?.addEventListener("focusout", updateDOMDislikes);
|
||||
preNavigateLikeButton = getLikeButton();
|
||||
|
||||
if (!smartimationObserver) {
|
||||
smartimationObserver = createObserver(
|
||||
{
|
||||
attributes: true,
|
||||
subtree: true,
|
||||
childList: true,
|
||||
},
|
||||
updateDOMDislikes,
|
||||
);
|
||||
smartimationObserver.container = null;
|
||||
}
|
||||
|
||||
const smartimationContainer = buttons.querySelector("yt-smartimation");
|
||||
if (smartimationContainer && smartimationObserver.container != smartimationContainer) {
|
||||
cLog("Initializing smartimation mutation observer");
|
||||
smartimationObserver.disconnect();
|
||||
smartimationObserver.observe(smartimationContainer);
|
||||
smartimationObserver.container = smartimationContainer;
|
||||
}
|
||||
} catch {
|
||||
return;
|
||||
} //Don't spam errors into the console
|
||||
window.returnDislikeButtonlistenersSet = true;
|
||||
}
|
||||
setInitialState();
|
||||
clearInterval(jsInitChecktimer);
|
||||
if (dislikeButton) {
|
||||
setInitialState();
|
||||
clearInterval(jsInitChecktimer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,12 +694,11 @@ if (isMobile) {
|
||||
return originalPush.apply(history, args);
|
||||
};
|
||||
setInterval(() => {
|
||||
if(getDislikeButton().querySelector(".button-renderer-text") === null){
|
||||
const dislikeButton = getDislikeButton();
|
||||
if (dislikeButton?.querySelector(".button-renderer-text") === null) {
|
||||
getDislikeTextContainer().innerText = mobileDislikes;
|
||||
}
|
||||
else{
|
||||
getDislikeButton().querySelector(".button-renderer-text").innerText =
|
||||
mobileDislikes;
|
||||
} else {
|
||||
if (dislikeButton) dislikeButton.querySelector(".button-renderer-text").innerText = mobileDislikes;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
{
|
||||
"extensionName": {
|
||||
"message": "YouTube Dislike Sayını Geri Qaytar"
|
||||
},
|
||||
"extensionNameBeta": {
|
||||
"message": "YouTube Dislike Sayını Geri Qaytar Beta"
|
||||
},
|
||||
"extensionDesc": {
|
||||
"message": "Dislike-ları görmə qabiliyyəti verir"
|
||||
},
|
||||
"textDeveloper": {
|
||||
"message": "Dmitry Selivanov və İcma tərəfindən"
|
||||
},
|
||||
"linkWebsite": {
|
||||
"message": "Sayt"
|
||||
},
|
||||
"linkFAQ": {
|
||||
"message": "Tez-tez verilən suallar"
|
||||
},
|
||||
"linkDonate": {
|
||||
"message": "Bağış Et"
|
||||
},
|
||||
"linkHelp": {
|
||||
"message": "Kömək"
|
||||
},
|
||||
"linkChangelog": {
|
||||
"message": "Dəyişiklik Jurnalı"
|
||||
},
|
||||
"legendSettings": {
|
||||
"message": "Parametrlər"
|
||||
},
|
||||
"textSettings": {
|
||||
"message": "Like/dislike göndərməsini deaktiv et"
|
||||
},
|
||||
"textLikesDisabled": {
|
||||
"message": "Sahibi tərəfindən deaktiv edilib"
|
||||
},
|
||||
"textSettingsHover": {
|
||||
"message": "Like və dislike-larınızı saymağı dayandırır."
|
||||
},
|
||||
"textRoundingNumbers": {
|
||||
"message": "Like/dislike statistikasını aşağı yuvarlayır (standart YouTube davranışı)"
|
||||
},
|
||||
"textRoundingNumbersHover": {
|
||||
"message": "Yuvarlanmış statistikaları göstər."
|
||||
},
|
||||
"textConsistentFormat": {
|
||||
"message": "Like və dislike formatını uyğunlaşdırır"
|
||||
},
|
||||
"textConsistentFormatHover": {
|
||||
"message": "Like sayılarının formatını yeniləyir."
|
||||
},
|
||||
"textNumberFormat": {
|
||||
"message": "Sayı formatı:"
|
||||
},
|
||||
"textColorizeRatioBar": {
|
||||
"message": "Bəyənmə nisbəti çubuğunu rəngləndir"
|
||||
},
|
||||
"textColorizeRatioBarHover": {
|
||||
"message": "Nisbət çubuğu üçün xüsusi rənglər istifadə edin."
|
||||
},
|
||||
"textColorizeThumbs": {
|
||||
"message": "Düymələri rəngləndir"
|
||||
},
|
||||
"textColorizeThumbsHover": {
|
||||
"message": "Düymə simvolları üçün xüsusi rənglər istifadə edin."
|
||||
},
|
||||
"textColorTheme": {
|
||||
"message": "Rəng mövzusu:"
|
||||
},
|
||||
"textColorTheme1": {
|
||||
"message": "Klassik"
|
||||
},
|
||||
"textColorTheme2": {
|
||||
"message": "Aydın"
|
||||
},
|
||||
"textColorTheme3": {
|
||||
"message": "Neon"
|
||||
},
|
||||
"textTempUnavailable": {
|
||||
"message": "Müvəqqəti olaraq istifadədən kənar"
|
||||
},
|
||||
"textUpdate": {
|
||||
"message": "Bu versiyaya yenilə"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Versiya __RYD_VERSION__ yükləndi"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Yeniliklər"
|
||||
},
|
||||
"shortsSupport": {
|
||||
"message": "YouTube Shorts Dəstəyi"
|
||||
},
|
||||
"customColors": {
|
||||
"message": "Dislike çubuğu və düymələr üçün xüsusi rənglər"
|
||||
},
|
||||
"customNumberFormats": {
|
||||
"message": "Xüsusi say formatları"
|
||||
},
|
||||
"considerDonating": {
|
||||
"message": "Uzantının mövcud olmasını təmin edən tək şey ianələrinizdir, lütfən layihəni dəstəkləməyi düşünün."
|
||||
},
|
||||
"roundNumbers": {
|
||||
"message": "Aşağı yuvarlanmış sayıları göstərir"
|
||||
},
|
||||
"roundNumbersHover": {
|
||||
"message": "Sayıları aşağıya yuvarla (standart YouTube davranışı)."
|
||||
},
|
||||
"reformatLikes": {
|
||||
"message": "Like sayılarının formatını yeniləyir"
|
||||
},
|
||||
"reformatLikesHover": {
|
||||
"message": "Like və dislike formatını uyğunlaşdırır."
|
||||
},
|
||||
"numberFormat": {
|
||||
"message": "Sayı formatı:"
|
||||
},
|
||||
"colorizeRatio": {
|
||||
"message": "Bəyənmə nisbəti çubuğunu rəngləndir"
|
||||
},
|
||||
"colorizeRatioHover": {
|
||||
"message": "Bəyənmə nisbəti çubuğu üçün xüsusi rənglər istifadə edin."
|
||||
},
|
||||
"colorizeThumbs": {
|
||||
"message": "Düymələri rəngləndir"
|
||||
},
|
||||
"colorizeThumbsHover": {
|
||||
"message": "Düymə simvolları üçün xüsusi rənglər istifadə edin."
|
||||
},
|
||||
"colorTheme": {
|
||||
"message": "Rəng mövzusu:"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"message": "aktualizovat na"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Verze 3.0.0.13 nainstalována"
|
||||
"message": "Verze __RYD_VERSION__ nainstalována"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Co je nového"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"message": "Macht Dislikes wieder sichtbar"
|
||||
},
|
||||
"textDeveloper": {
|
||||
"message": "von Dmitry Selivanov & Community"
|
||||
"message": "von Dmitry Selivanov & der Community"
|
||||
},
|
||||
"linkWebsite": {
|
||||
"message": "Website"
|
||||
@@ -23,20 +23,68 @@
|
||||
"linkHelp": {
|
||||
"message": "Hilfe"
|
||||
},
|
||||
"linkChangelog": {
|
||||
"message": "Änderungshistorie"
|
||||
},
|
||||
"legendSettings": {
|
||||
"message": "Einstellungen"
|
||||
},
|
||||
"textSettings": {
|
||||
"message": "Deaktiviere Like/Dislike-Übermittlung"
|
||||
},
|
||||
"textLikesDisabled": {
|
||||
"message": "Deaktiviert vom Ersteller"
|
||||
},
|
||||
"textSettingsHover": {
|
||||
"message": "Stoppt deine Likes und Dislikes zu zählen."
|
||||
},
|
||||
"textRoundingNumbers": {
|
||||
"message": "Runde Likes/Dislikes ab (Standardverhalten von YouTube)"
|
||||
},
|
||||
"textRoundingNumbersHover": {
|
||||
"message": "Zeige abgerundete Zahlen."
|
||||
},
|
||||
"textConsistentFormat": {
|
||||
"message": "Das Format der Likes und Dislikes einheitlich machen."
|
||||
},
|
||||
"textConsistentFormatHover": {
|
||||
"message": "Likes neu formatieren"
|
||||
},
|
||||
"textNumberFormat": {
|
||||
"message": "Zahlenformat:"
|
||||
},
|
||||
"textColorizeRatioBar": {
|
||||
"message": "Verhältnisbalken einfärben"
|
||||
},
|
||||
"textColorizeRatioBarHover": {
|
||||
"message": "Benutzerdefinierte Farben für die Verhältnisleiste verwenden."
|
||||
},
|
||||
"textColorizeThumbs": {
|
||||
"message": "Like/Dislike-Icons einfärben"
|
||||
},
|
||||
"textColorizeThumbsHover": {
|
||||
"message": "Benutzerdefinierte Farben für die Like/Dislike-Icons verwenden."
|
||||
},
|
||||
"textColorTheme": {
|
||||
"message": "Farbschema:"
|
||||
},
|
||||
"textColorTheme1": {
|
||||
"message": "Klassisch"
|
||||
},
|
||||
"textColorTheme2": {
|
||||
"message": "Barrierefrei"
|
||||
},
|
||||
"textColorTheme3": {
|
||||
"message": "Neon"
|
||||
},
|
||||
"textTempUnavailable": {
|
||||
"message": "Temporär nicht verfügbar"
|
||||
},
|
||||
"textUpdate": {
|
||||
"message": "aktualisieren auf"
|
||||
"message": "Aktualisieren auf"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Version 3.0.0.13 installiert"
|
||||
"message": "Version __RYD_VERSION__ installiert"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Was ist neu"
|
||||
@@ -45,7 +93,7 @@
|
||||
"message": "YouTube Shorts Unterstützung"
|
||||
},
|
||||
"customColors": {
|
||||
"message": "Benutzerdefinierte Farben für Dislike-Leiste und Buttons"
|
||||
"message": "Benutzerdefinierte Farben für die Dislike-Leiste und Knopf"
|
||||
},
|
||||
"customNumberFormats": {
|
||||
"message": "Benutzerdefinierte Zahlenformate"
|
||||
@@ -60,10 +108,10 @@
|
||||
"message": "Zahlen abrunden (Standardverhalten von YouTube)."
|
||||
},
|
||||
"reformatLikes": {
|
||||
"message": "Wie Zahlen neu formatieren"
|
||||
"message": "Likes neu formatieren"
|
||||
},
|
||||
"reformatLikesHover": {
|
||||
"message": "Machen Sie das Format der Vorlieben und Abneigungen konsistent."
|
||||
"message": "Das Format der Likes und Dislikes einheitlich machen."
|
||||
},
|
||||
"numberFormat": {
|
||||
"message": "Zahlenformat:"
|
||||
@@ -75,10 +123,10 @@
|
||||
"message": "Benutzerdefinierte Farben für die Verhältnisleiste verwenden."
|
||||
},
|
||||
"colorizeThumbs": {
|
||||
"message": "Buttons einfärben"
|
||||
"message": "Like/Dislike-Icons eifärben"
|
||||
},
|
||||
"colorizeThumbsHover": {
|
||||
"message": "Benutzerdefinierte Farben für die Schaltflächensymbole verwenden."
|
||||
"message": "Benutzerdefinierte Farben für die Like/Dislike-Icons verwenden."
|
||||
},
|
||||
"colorTheme": {
|
||||
"message": "Farbschema:"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"extensionName": {
|
||||
"message": "Επιστροφή του YouTube Dislike"
|
||||
"message": "Επαναφορά του YouTube Dislike"
|
||||
},
|
||||
"extensionNameBeta": {
|
||||
"message": "Return YouTube Dislike Beta"
|
||||
},
|
||||
"extensionDesc": {
|
||||
"message": "Επιστρέφει τα dislikes"
|
||||
"message": "Επαναφέρει τη δυνατότητα να βλέπετε τα dislikes"
|
||||
},
|
||||
"textDeveloper": {
|
||||
"message": "από τον Dmitry Selivanov & την κοινότητα"
|
||||
@@ -84,7 +84,7 @@
|
||||
"message": "Ενημέρωση σε"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Εκδοση 3.0.0.13 εγκαταστάθηκε"
|
||||
"message": "Εκδοση __RYD_VERSION__ εγκαταστάθηκε"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Τί νέο υπάρχει"
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
"message": "Update to"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Version 3.0.0.13 installed"
|
||||
"message": "Version __RYD_VERSION__ installed"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "What's new"
|
||||
@@ -130,5 +130,17 @@
|
||||
},
|
||||
"colorTheme": {
|
||||
"message": "Color theme:"
|
||||
},
|
||||
"showTooltipPercentage": {
|
||||
"message": "Percentage in like/dislike bar tooltip."
|
||||
},
|
||||
"showTooltipPercentageHover": {
|
||||
"message": "Display percentage in like/dislike bar tooltip."
|
||||
},
|
||||
"tooltipPercentageMode": {
|
||||
"message": "Percent mode:"
|
||||
},
|
||||
"tooltipPercentageModeHover": {
|
||||
"message": "Use custom percentage display on hover."
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
"message": "actualizar a"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Versión 3.0.0.13 instalada"
|
||||
"message": "Versión __RYD_VERSION__ instalada"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Novedades"
|
||||
@@ -130,5 +130,17 @@
|
||||
},
|
||||
"colorTheme": {
|
||||
"message": "Combinación de colores:"
|
||||
},
|
||||
"showTooltipPercentage": {
|
||||
"message": "Porcentaje en el tooltip de la barra de like/dislike."
|
||||
},
|
||||
"showTooltipPercentageHover": {
|
||||
"message": "Mostrar porcentaje en el tooltip de la barra de like/dislike."
|
||||
},
|
||||
"tooltipPercentageMode": {
|
||||
"message": "Modo de porcentaje:"
|
||||
},
|
||||
"tooltipPercentageModeHover": {
|
||||
"message": "Usar visualización de porcentaje personalizada al pasar el puntero."
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@
|
||||
"message": "mettre à jour vers"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Version 3.0.0.13 installée"
|
||||
"message": "Version __RYD_VERSION__ installée"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Quoi de neuf"
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"extensionName": {
|
||||
"message": "Return YouTube Dislike"
|
||||
},
|
||||
"extensionNameBeta": {
|
||||
"message": "Return YouTube Dislike Beta"
|
||||
},
|
||||
"extensionDesc": {
|
||||
"message": "Visszaállítja a dislike számlálót"
|
||||
},
|
||||
"textDeveloper": {
|
||||
"message": "Készítő: Dmitry Selivanov & Community"
|
||||
},
|
||||
"linkWebsite": {
|
||||
"message": "Weboldal"
|
||||
},
|
||||
"linkFAQ": {
|
||||
"message": "GYIK"
|
||||
},
|
||||
"linkDonate": {
|
||||
"message": "Támogatás"
|
||||
},
|
||||
"linkHelp": {
|
||||
"message": "Segítség"
|
||||
},
|
||||
"legendSettings": {
|
||||
"message": "Beállítások"
|
||||
},
|
||||
"textSettings": {
|
||||
"message": "Like/Dislike beküldés kikapcsolása"
|
||||
},
|
||||
"textLikesDisabled": {
|
||||
"message": "tulajdonos által kikapcsolva"
|
||||
},
|
||||
"textSettingsHover": {
|
||||
"message": "Nem számolja tovább a like és dislike adataidat."
|
||||
},
|
||||
"textTempUnavailable": {
|
||||
"message": "temp n/a"
|
||||
},
|
||||
"textUpdate": {
|
||||
"message": "frissítés erre:"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "3.0.0.1 verzió telepítve"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Újdonságok"
|
||||
},
|
||||
"shortsSupport": {
|
||||
"message": "YouTube Shorts támogatás"
|
||||
},
|
||||
"customColors": {
|
||||
"message": "Egyéni színek a dislike csíkon és gombon"
|
||||
},
|
||||
"customNumberFormats": {
|
||||
"message": "Egyéni számformátum"
|
||||
},
|
||||
"considerDonating": {
|
||||
"message": "Ez a bővítmény kizárólag a támogatásoknak köszönhetően működik. Kérjük, támogasd a projektet!"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"extensionName": {
|
||||
"message": "Return YouTube Dislike"
|
||||
},
|
||||
"extensionNameBeta": {
|
||||
"message": "Return YouTube Dislike Beta"
|
||||
},
|
||||
"extensionDesc": {
|
||||
"message": "Mengembalikan kemampuan untuk melihat jumlah dislike"
|
||||
},
|
||||
"textDeveloper": {
|
||||
"message": "oleh Dmitry Selivanov & Komunitas"
|
||||
},
|
||||
"linkWebsite": {
|
||||
"message": "Website"
|
||||
},
|
||||
"linkFAQ": {
|
||||
"message": "Pertanyaan"
|
||||
},
|
||||
"linkDonate": {
|
||||
"message": "Donasi"
|
||||
},
|
||||
"linkHelp": {
|
||||
"message": "Bantuan"
|
||||
},
|
||||
"linkChangelog": {
|
||||
"message": "Log Perubahan"
|
||||
},
|
||||
"legendSettings": {
|
||||
"message": "Pengaturan"
|
||||
},
|
||||
"textSettings": {
|
||||
"message": "Matikan pengiriman like/dislike"
|
||||
},
|
||||
"textLikesDisabled": {
|
||||
"message": "Dimatikan oleh Pemilik"
|
||||
},
|
||||
"textSettingsHover": {
|
||||
"message": "Memberhentikan penghitungan like dan dislikemu"
|
||||
},
|
||||
"textRoundingNumbers": {
|
||||
"message": "Membulatkan data like/dislike kebawah (bawaan YouTube)"
|
||||
},
|
||||
"textRoundingNumbersHover": {
|
||||
"message": "Munculkan data pembulatan kebawah."
|
||||
},
|
||||
"textConsistentFormat": {
|
||||
"message": "Membuat format like dan dislike konsisten"
|
||||
},
|
||||
"textConsistentFormatHover": {
|
||||
"message": "Format ulang jumlah like."
|
||||
},
|
||||
"textNumberFormat": {
|
||||
"message": "Format angka:"
|
||||
},
|
||||
"textColorizeRatioBar": {
|
||||
"message": "Warnai bar rasio"
|
||||
},
|
||||
"textColorizeRatioBarHover": {
|
||||
"message": "Gunakan warna kustom bar rasio."
|
||||
},
|
||||
"textColorizeThumbs": {
|
||||
"message": "Warnai jempol"
|
||||
},
|
||||
"textColorizeThumbsHover": {
|
||||
"message": "Gunakan warna kustom untuk ikon jempol."
|
||||
},
|
||||
"textColorTheme": {
|
||||
"message": "Warnai tema:"
|
||||
},
|
||||
"textColorTheme1": {
|
||||
"message": "Klasik"
|
||||
},
|
||||
"textColorTheme2": {
|
||||
"message": "Mudah diakses"
|
||||
},
|
||||
"textColorTheme3": {
|
||||
"message": "Neon"
|
||||
},
|
||||
"textTempUnavailable": {
|
||||
"message": "Tidak Ada Untuk Sementara Waktu"
|
||||
},
|
||||
"textUpdate": {
|
||||
"message": "Update ke"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Versi __RYD_VERSION__ terinstall"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Apa yang baru"
|
||||
},
|
||||
"shortsSupport": {
|
||||
"message": "Mendukung YouTube Short"
|
||||
},
|
||||
"customColors": {
|
||||
"message": "Warna kustom untuk bar dislike dan tombol"
|
||||
},
|
||||
"customNumberFormats": {
|
||||
"message": "Format angka kustom"
|
||||
},
|
||||
"considerDonating": {
|
||||
"message": "Donasimulah yang hanya bisa membuat extension ini terus berjalan, tolong pertimbangkan untuk mendukung proyek ini."
|
||||
},
|
||||
"roundNumbers": {
|
||||
"message": "Munculkan angka yang dibulatkan kebawah"
|
||||
},
|
||||
"roundNumbersHover": {
|
||||
"message": "Bulatkan angka kebawah (bawaan YouTube)."
|
||||
},
|
||||
"reformatLikes": {
|
||||
"message": "Format ulang jumlah like"
|
||||
},
|
||||
"reformatLikesHover": {
|
||||
"message": "Membuat format like dan dislike konsisten."
|
||||
},
|
||||
"numberFormat": {
|
||||
"message": "Format angka:"
|
||||
},
|
||||
"colorizeRatio": {
|
||||
"message": "Warnai bar rasio"
|
||||
},
|
||||
"colorizeRatioHover": {
|
||||
"message": "Gunakan warna kustom untuk rasio bar."
|
||||
},
|
||||
"colorizeThumbs": {
|
||||
"message": "Warnai jempol"
|
||||
},
|
||||
"colorizeThumbsHover": {
|
||||
"message": "Gunakan warna kustom untuk ikon jempol."
|
||||
},
|
||||
"colorTheme": {
|
||||
"message": "Warnai tema:"
|
||||
}
|
||||
}
|
||||
@@ -6,81 +6,129 @@
|
||||
"message": "Return YouTube Dislike Beta"
|
||||
},
|
||||
"extensionDesc": {
|
||||
"message": "Ripristina la possibilità di vedere i dislikes"
|
||||
"message": "Riporta il numero di Non mi piace"
|
||||
},
|
||||
"textDeveloper": {
|
||||
"message": "grazie a Dmitry Selivanov e alla Comunità"
|
||||
"message": "di Dmitry Selivanov e della comunità"
|
||||
},
|
||||
"linkWebsite": {
|
||||
"message": "Sito web"
|
||||
},
|
||||
"linkFAQ": {
|
||||
"message": "Domande frequenti"
|
||||
"message": "FAQ"
|
||||
},
|
||||
"linkDonate": {
|
||||
"message": "Fai una donazione"
|
||||
"message": "Dona"
|
||||
},
|
||||
"linkHelp": {
|
||||
"message": "Aiuto"
|
||||
},
|
||||
"linkChangelog": {
|
||||
"message": "Note di versione"
|
||||
},
|
||||
"legendSettings": {
|
||||
"message": "Impostazioni"
|
||||
},
|
||||
"textSettings": {
|
||||
"message": "Disabilita l'invio dei like e dei dislike"
|
||||
"message": "Disattiva invio di Mi piace/Non mi piace"
|
||||
},
|
||||
"textLikesDisabled": {
|
||||
"message": "Disattivati dal proprietario"
|
||||
},
|
||||
"textSettingsHover": {
|
||||
"message": "Interrompe il conteggio dei tuoi likes e dislikes da parte dell'estensione."
|
||||
"message": "Smette di contare i tuoi Mi piace e Non mi piace."
|
||||
},
|
||||
"textRoundingNumbers": {
|
||||
"message": "Arrotonda per difetto il numero di Mi Piace/Non mi piace (comportamento standard di YouTube)."
|
||||
},
|
||||
"textRoundingNumbersHover": {
|
||||
"message": "Mostra stastistiche arrotondate per difetto."
|
||||
},
|
||||
"textConsistentFormat": {
|
||||
"message": "Rendi uniforme il formato di Mi piace e Non mi piace."
|
||||
},
|
||||
"textConsistentFormatHover": {
|
||||
"message": "Ri-formatta numero di Mi piace."
|
||||
},
|
||||
"textNumberFormat": {
|
||||
"message": "Formato numeri:"
|
||||
},
|
||||
"textColorizeRatioBar": {
|
||||
"message": "Colora barra di rapporto"
|
||||
},
|
||||
"textColorizeRatioBarHover": {
|
||||
"message": "Usa colori personalizzati per la barra di rapporto."
|
||||
},
|
||||
"textColorizeThumbs": {
|
||||
"message": "Colora pollici"
|
||||
},
|
||||
"textColorizeThumbsHover": {
|
||||
"message": "Usa colori personalizzati per le icone dei pollici."
|
||||
},
|
||||
"textColorTheme": {
|
||||
"message": "Colore tema:"
|
||||
},
|
||||
"textColorTheme1": {
|
||||
"message": "Classico"
|
||||
},
|
||||
"textColorTheme2": {
|
||||
"message": "Accessibile"
|
||||
},
|
||||
"textColorTheme3": {
|
||||
"message": "Neon"
|
||||
},
|
||||
"textTempUnavailable": {
|
||||
"message": "Temporaneamente non disponibile"
|
||||
},
|
||||
"textUpdate": {
|
||||
"message": "aggiorna a"
|
||||
"message": "Aggiorna a"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Versione 3.0.0.13 installata"
|
||||
"message": "Versione __RYD_VERSION__ installata"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Quali sono le novità"
|
||||
"message": "Novità"
|
||||
},
|
||||
"shortsSupport": {
|
||||
"message": "Supporto per YouTube Shorts"
|
||||
},
|
||||
"customColors": {
|
||||
"message": "Colori personalizzati per la barra dei dislike e i bottoni"
|
||||
"message": "Colori personalizzati per barra dei Non mi piace e bottoni"
|
||||
},
|
||||
"customNumberFormats": {
|
||||
"message": "Formati numerici personalizzati"
|
||||
"message": "Formato numeri personalizzato"
|
||||
},
|
||||
"considerDonating": {
|
||||
"message": "Le uniche cosa che tengono in piedi il progetto sono le vostre donazioni. Per favore, considera di effettuare una donazione per supportarci. Grazie."
|
||||
"message": "L'unica cosa che manda avanti questa estensione sono le tue donazioni, valuta se sostenere il progetto."
|
||||
},
|
||||
"roundNumbers": {
|
||||
"message": "Mostra i numeri arrotondati"
|
||||
"message": "Mostra numeri arrotondati per difetto"
|
||||
},
|
||||
"roundNumbersHover": {
|
||||
"message": "Arrotonda il valore del conteggio (questa è l'opzione predefinita di YouTube)."
|
||||
"message": "Arrotonda numeri per difetto (comportamento standard di YouTube)."
|
||||
},
|
||||
"reformatLikes": {
|
||||
"message": "Formatta il numero di like"
|
||||
"message": "Ri-formatta numero Mi piace"
|
||||
},
|
||||
"reformatLikesHover": {
|
||||
"message": "Rende il valore delle statistiche più consistente."
|
||||
"message": "Rendi uniforme il formato di Mi piace e Non mi piace."
|
||||
},
|
||||
"numberFormat": {
|
||||
"message": "Formato numerico"
|
||||
"message": "Formato numeri:"
|
||||
},
|
||||
"colorizeRatio": {
|
||||
"message": "Colora la barra dei dislike"
|
||||
"message": "Colora barra di rapporto"
|
||||
},
|
||||
"colorizeRatioHover": {
|
||||
"message": "Colora la barra dei dislike con colori personalizzati."
|
||||
"message": "Usa colori personalizzati per la barra di rapporto."
|
||||
},
|
||||
"colorizeThumbs": {
|
||||
"message": "Colora i pulsanti"
|
||||
"message": "Colora pollici"
|
||||
},
|
||||
"colorizeThumbsHover": {
|
||||
"message": "Colora i pulsanti dei like e dei dislike con colori personalizzati."
|
||||
"message": "Usa colori personalizzati per le icone dei pollici."
|
||||
},
|
||||
"colorTheme": {
|
||||
"message": "Schema colori:"
|
||||
"message": "Colore tema:"
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@
|
||||
"message": "アップデート:"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "バージョン 3.0.0.13 がインストールされました。"
|
||||
"message": "バージョン __RYD_VERSION__ がインストールされました。"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "新機能"
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
"message": "업데이트"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "3.0.0.13 버전이 설치됨"
|
||||
"message": "__RYD_VERSION__ 버전이 설치됨"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "새로운 점"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
|
||||
"extensionName": {
|
||||
"message": "Return YouTube Dislike"
|
||||
},
|
||||
@@ -6,7 +7,7 @@
|
||||
"message": "Return YouTube Dislike Beta"
|
||||
},
|
||||
"extensionDesc": {
|
||||
"message": "Retourneert het vermogen om dislikes te zien"
|
||||
"message": "Herstelt de functie om dislikes te kunnen zien"
|
||||
},
|
||||
"textDeveloper": {
|
||||
"message": "door Dmitry Selivanov & Gemeenschap"
|
||||
@@ -24,7 +25,7 @@
|
||||
"message": "Help"
|
||||
},
|
||||
"linkChangelog": {
|
||||
"message": "Wijzig-log"
|
||||
"message": "Wijzigingslog"
|
||||
},
|
||||
"legendSettings": {
|
||||
"message": "Instellingen"
|
||||
@@ -51,7 +52,7 @@
|
||||
"message": "Herformatteer als getallen."
|
||||
},
|
||||
"textNumberFormat": {
|
||||
"message": "Nummer formaat:"
|
||||
"message": "Getalnotatie:"
|
||||
},
|
||||
"textColorizeRatioBar": {
|
||||
"message": "Verhoudingsbalk inkleuren"
|
||||
@@ -60,13 +61,13 @@
|
||||
"message": "Gebruik aangepaste kleuren voor de verhoudingsbalk."
|
||||
},
|
||||
"textColorizeThumbs": {
|
||||
"message": "Duimen inkleuren"
|
||||
"message": "Duimpjes inkleuren"
|
||||
},
|
||||
"textColorizeThumbsHover": {
|
||||
"message": "Gebruik aangepaste kleuren voor duimpictogrammen."
|
||||
},
|
||||
"textColorTheme": {
|
||||
"message": "Kleuren thema:"
|
||||
"message": "Kleurenthema:"
|
||||
},
|
||||
"textColorTheme1": {
|
||||
"message": "Klassiek"
|
||||
@@ -81,7 +82,7 @@
|
||||
"message": "Tijdelijk niet beschikbaar"
|
||||
},
|
||||
"textUpdate": {
|
||||
"message": "Update naar"
|
||||
"message": "Actualiseer naar"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Versie 3.0.0.13 geïnstalleerd"
|
||||
@@ -90,7 +91,7 @@
|
||||
"message": "Wat is er nieuw"
|
||||
},
|
||||
"shortsSupport": {
|
||||
"message": "YouTube Shorts Ondersteuning"
|
||||
"message": "Ondersteuning voor YouTube Shorts"
|
||||
},
|
||||
"customColors": {
|
||||
"message": "Aangepaste kleuren voor afkeerbalk en knoppen"
|
||||
@@ -99,7 +100,7 @@
|
||||
"message": "Aangepaste getalnotaties"
|
||||
},
|
||||
"considerDonating": {
|
||||
"message": "Het enige dat de extensie draaiende houdt, zijn uw donaties, overweeg alstublieft om het project te steunen."
|
||||
"message": "Het enige dat de extensie draaiende houdt, zijn uw donaties. Overweeg alstublieft om het project te steunen."
|
||||
},
|
||||
"roundNumbers": {
|
||||
"message": "Afgeronde getallen weergeven"
|
||||
@@ -114,7 +115,7 @@
|
||||
"message": "Maak het formaat voor leuk en niet leuk consistent."
|
||||
},
|
||||
"numberFormat": {
|
||||
"message": "Nummer formaat:"
|
||||
"message": "Getalnotatie:"
|
||||
},
|
||||
"colorizeRatio": {
|
||||
"message": "Verhoudingsbalk inkleuren"
|
||||
@@ -123,12 +124,12 @@
|
||||
"message": "Gebruik aangepaste kleuren voor de verhoudingsbalk."
|
||||
},
|
||||
"colorizeThumbs": {
|
||||
"message": "Duimen inkleuren"
|
||||
"message": "Duimpjes inkleuren"
|
||||
},
|
||||
"colorizeThumbsHover": {
|
||||
"message": "Gebruik aangepaste kleuren voor de duimpictogrammen."
|
||||
},
|
||||
"colorTheme": {
|
||||
"message": "Kleuren thema:"
|
||||
"message": "Kleurenthema:"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
"message": "Zaktualizuj do"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Zainstalowana wersja 3.0.0.1"
|
||||
"message": "Zainstalowana wersja __RYD_VERSION__"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Co nowego"
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"extensionName": {
|
||||
"message": "Voltar Dislikes do YouTube"
|
||||
"message": "Volta Descurtidas do YouTube"
|
||||
},
|
||||
"extensionNameBeta": {
|
||||
"message": "Voltar Dislikes do YouTube Beta"
|
||||
"message": "Volta Descurtidas do YouTube Beta"
|
||||
},
|
||||
"extensionDesc": {
|
||||
"message": "Voltar os Deslikes do YouTube"
|
||||
"message": "Retorna a capacidade de ver descurtidas"
|
||||
},
|
||||
"textDeveloper": {
|
||||
"message": "por Dmitry Selivanov e Comunidade"
|
||||
"message": "por Dmitry Selivanov & Comunidade"
|
||||
},
|
||||
"linkWebsite": {
|
||||
"message": "Website"
|
||||
@@ -18,45 +18,117 @@
|
||||
"message": "Perguntas Frequentes"
|
||||
},
|
||||
"linkDonate": {
|
||||
"message": "Doe"
|
||||
"message": "Doar"
|
||||
},
|
||||
"linkHelp": {
|
||||
"message": "Ajuda"
|
||||
},
|
||||
"linkChangelog": {
|
||||
"message": "Registro de alterações"
|
||||
},
|
||||
"legendSettings": {
|
||||
"message": "Configurações"
|
||||
},
|
||||
"textSettings": {
|
||||
"message": "Desativar envio de Curtidas/Não Curtidas"
|
||||
"message": "Desativar envio de curtidas/descurtidas"
|
||||
},
|
||||
"textLikesDisabled": {
|
||||
"message": "Desativado pelo proprietário"
|
||||
},
|
||||
"textSettingsHover": {
|
||||
"message": "Parar de contar suas curtidas e não curtidas."
|
||||
"message": "Para de contar suas curtidas e descurtidas."
|
||||
},
|
||||
"textRoundingNumbers": {
|
||||
"message": "Arredondar as estatísticas de curtidas/descurtidas para baixo (comportamento padrão do YouTube)"
|
||||
},
|
||||
"textRoundingNumbersHover": {
|
||||
"message": "Mostrar estatísticas arredondadas"
|
||||
},
|
||||
"textConsistentFormat": {
|
||||
"message": "Tornar o formato de curtidas e descurtidas consistente"
|
||||
},
|
||||
"textConsistentFormatHover": {
|
||||
"message": "Re-formatar número de curtidas."
|
||||
},
|
||||
"textNumberFormat": {
|
||||
"message": "Formato numérico:"
|
||||
},
|
||||
"textColorizeRatioBar": {
|
||||
"message": "Colorir barra de proporção"
|
||||
},
|
||||
"textColorizeRatioBarHover": {
|
||||
"message": "Usar cores personalizadas para a barra de proporção."
|
||||
},
|
||||
"textColorizeThumbs": {
|
||||
"message": "Colorir botões"
|
||||
},
|
||||
"textColorizeThumbsHover": {
|
||||
"message": "Usar cores personalizadas para os botões de curtir e descurtir."
|
||||
},
|
||||
"textColorTheme": {
|
||||
"message": "Tema de cores:"
|
||||
},
|
||||
"textColorTheme1": {
|
||||
"message": "Clássico"
|
||||
},
|
||||
"textColorTheme2": {
|
||||
"message": "Acessível"
|
||||
},
|
||||
"textColorTheme3": {
|
||||
"message": "Néon"
|
||||
},
|
||||
"textTempUnavailable": {
|
||||
"message": "Temporariamente indisponível"
|
||||
"message": "Temporariamente Indisponível"
|
||||
},
|
||||
"textUpdate": {
|
||||
"message": "Atualizar para"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Versão 3.0.0.13 instalada"
|
||||
"message": "Versão __RYD_VERSION__ instalada"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "O que há de novo?"
|
||||
"message": "O que há de novo?:"
|
||||
},
|
||||
"shortsSupport": {
|
||||
"message": "Suporte para Shorts"
|
||||
"message": "Suporte a curtas do YouTube"
|
||||
},
|
||||
"customColors": {
|
||||
"message": "Cores personalizadas para barra de não curtidas e botões"
|
||||
"message": "Cores personalizadas para barra de proporção e botões"
|
||||
},
|
||||
"customNumberFormats": {
|
||||
"message": "Formato de números personalizados"
|
||||
"message": "Formato numérico personalizado"
|
||||
},
|
||||
"considerDonating": {
|
||||
"message": "A única coisa que mantém a extensão funcionando são suas doações, considere apoiar o projeto."
|
||||
},
|
||||
"roundNumbers": {
|
||||
"message": "Mostrar números arredondados"
|
||||
},
|
||||
"roundNumbersHover": {
|
||||
"message": "Arredondar os números para baixo (comportamento padrão do YouTube)."
|
||||
},
|
||||
"reformatLikes": {
|
||||
"message": "Re-formatar número de curtidas"
|
||||
},
|
||||
"reformatLikesHover": {
|
||||
"message": "Tornar o formato de curtidas e descurtidas consistente."
|
||||
},
|
||||
"numberFormat": {
|
||||
"message": "Formato numérico:"
|
||||
},
|
||||
"colorizeRatio": {
|
||||
"message": "Colorir barra de proporção"
|
||||
},
|
||||
"colorizeRatioHover": {
|
||||
"message": "Usar cores personalizadas para a barra de proporção."
|
||||
},
|
||||
"colorizeThumbs": {
|
||||
"message": "Colorir botões"
|
||||
},
|
||||
"colorizeThumbsHover": {
|
||||
"message": "Usar cores personalizadas para os botões de curtir e descurtir."
|
||||
},
|
||||
"colorTheme": {
|
||||
"message": "Tema de Cores:"
|
||||
}
|
||||
}
|
||||
@@ -23,20 +23,68 @@
|
||||
"linkHelp": {
|
||||
"message": "Помощь"
|
||||
},
|
||||
"linkChangelog": {
|
||||
"message": "Журнал изменений"
|
||||
},
|
||||
"legendSettings": {
|
||||
"message": "Настройки"
|
||||
},
|
||||
"textSettings": {
|
||||
"message": "Отключить отправку лайков/дизлайков"
|
||||
},
|
||||
"textLikesDisabled": {
|
||||
"message": "Отключено владельцем"
|
||||
},
|
||||
"textSettingsHover": {
|
||||
"message": "Отключает отправку ваших отметок нравится/не нравится"
|
||||
},
|
||||
"textRoundingNumbers": {
|
||||
"message": "Округлить статистику лайков/дизлайков (стандартное поведение YouTube)"
|
||||
},
|
||||
"textRoundingNumbersHover": {
|
||||
"message": "Показывать округленные данные."
|
||||
},
|
||||
"textConsistentFormat": {
|
||||
"message": "Привести формат лайков и дизлайков к единому виду"
|
||||
},
|
||||
"textConsistentFormatHover": {
|
||||
"message": "Переформатировать число лайков."
|
||||
},
|
||||
"textNumberFormat": {
|
||||
"message": "Числовой формат:"
|
||||
},
|
||||
"textColorizeRatioBar": {
|
||||
"message": "Раскрасьте полосу неприязни"
|
||||
},
|
||||
"textColorizeRatioBarHover": {
|
||||
"message": "Используйте пользовательские цвета для полосы неприязни."
|
||||
},
|
||||
"textColorizeThumbs": {
|
||||
"message": "Раскрасьте кнопки"
|
||||
},
|
||||
"textColorizeThumbsHover": {
|
||||
"message": "Раскрасьте кнопки нравится и не нравится с помощью пользовательских цветов."
|
||||
},
|
||||
"textColorTheme": {
|
||||
"message": "Цветовая тема:"
|
||||
},
|
||||
"textColorTheme1": {
|
||||
"message": "Классическая"
|
||||
},
|
||||
"textColorTheme2": {
|
||||
"message": "Доступная"
|
||||
},
|
||||
"textColorTheme3": {
|
||||
"message": "Неоновая"
|
||||
},
|
||||
"textTempUnavailable": {
|
||||
"message": "Временно недоступно"
|
||||
},
|
||||
"textUpdate": {
|
||||
"message": "обновление до"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Версия 3.0.0.13 установлена"
|
||||
"message": "Версия __RYD_VERSION__ установлена"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Что нового"
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
"message": "Uppdatera till"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Version 3.0.0.13 installerad"
|
||||
"message": "Version __RYD_VERSION__ installerad"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Vad är nytt"
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
"message": "Şu sürüme güncelle"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Sürüm 3.0.0.13 yüklendi"
|
||||
"message": "Sürüm __RYD_VERSION__ yüklendi"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Yeni Ne Var"
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
"message": "Оновлення до"
|
||||
},
|
||||
"version30installed": {
|
||||
"message": "Версію 3.0.0.13 встановлено"
|
||||
"message": "Версію __RYD_VERSION__ встановлено"
|
||||
},
|
||||
"whatsnew": {
|
||||
"message": "Що нового"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" />
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg width="48" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M14.9 3H6c-.9 0-1.6.5-1.9 1.2l-3 7c-.1.3-.1.5-.1.7v2c0 1.1.9 2 2 2h6.3l-.9 4.5c-.1.5 0 1 .4 1.4l1.1 1.1 6.5-6.6c.4-.4.6-.9.6-1.4V5c-.1-1.1-1-2-2.1-2zm7.4 12.8h-2.9c-.4 0-.7-.3-.7-.7V3.9c0-.4.3-.7.7-.7h2.9c.4 0 .7.3.7.7V15c0 .4-.3.8-.7.8z"
|
||||
fill="red"
|
||||
/>
|
||||
<path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 420 B |
@@ -2,7 +2,7 @@
|
||||
"name": "__MSG_extensionName__",
|
||||
"description": "__MSG_extensionDesc__",
|
||||
"default_locale": "en",
|
||||
"version": "3.0.0.12",
|
||||
"version": "__RYD_VERSION__",
|
||||
"manifest_version": 3,
|
||||
"background": {
|
||||
"service_worker": "ryd.background.js"
|
||||
@@ -11,8 +11,12 @@
|
||||
"48": "icons/icon48.png",
|
||||
"128": "icons/icon128.png"
|
||||
},
|
||||
"host_permissions": ["*://*.youtube.com/*"],
|
||||
"permissions": ["storage"],
|
||||
"host_permissions": [
|
||||
"*://*.youtube.com/*"
|
||||
],
|
||||
"permissions": [
|
||||
"storage"
|
||||
],
|
||||
"action": {
|
||||
"default_popup": "popup.html"
|
||||
},
|
||||
@@ -23,18 +27,31 @@
|
||||
"*://www.youtube.com/*",
|
||||
"*://m.youtube.com/*"
|
||||
],
|
||||
"exclude_matches": ["*://*.music.youtube.com/*"],
|
||||
"js": ["ryd.content-script.js"],
|
||||
"css": ["content-style.css"]
|
||||
"exclude_matches": [
|
||||
"*://*.music.youtube.com/*"
|
||||
],
|
||||
"js": [
|
||||
"ryd.content-script.js"
|
||||
],
|
||||
"css": [
|
||||
"content-style.css"
|
||||
]
|
||||
}
|
||||
],
|
||||
"externally_connectable": {
|
||||
"matches": ["*://*.youtube.com/*"]
|
||||
"matches": [
|
||||
"*://*.youtube.com/*"
|
||||
]
|
||||
},
|
||||
"web_accessible_resources": [
|
||||
{
|
||||
"resources": ["ryd.script.js"],
|
||||
"matches": ["*://*.youtube.com/*"]
|
||||
"resources": [
|
||||
"ryd.script.js",
|
||||
"menu-fixer.js"
|
||||
],
|
||||
"matches": [
|
||||
"*://*.youtube.com/*"
|
||||
]
|
||||
}
|
||||
],
|
||||
"options_ui": {
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
"name": "__MSG_extensionName__",
|
||||
"description": "__MSG_extensionDesc__",
|
||||
"default_locale": "en",
|
||||
"version": "3.0.0.12",
|
||||
"version": "__RYD_VERSION__",
|
||||
"manifest_version": 2,
|
||||
"background": {
|
||||
"scripts": ["ryd.background.js"]
|
||||
"scripts": [
|
||||
"ryd.background.js"
|
||||
]
|
||||
},
|
||||
"icons": {
|
||||
"48": "icons/icon48.png",
|
||||
@@ -22,19 +24,31 @@
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["*://*.youtube.com/*"],
|
||||
"exclude_matches": ["*://*.music.youtube.com/*"],
|
||||
"matches": [
|
||||
"*://*.youtube.com/*"
|
||||
],
|
||||
"exclude_matches": [
|
||||
"*://*.music.youtube.com/*"
|
||||
],
|
||||
"run_at": "document_idle",
|
||||
"css": ["content-style.css"],
|
||||
"js": ["ryd.content-script.js"]
|
||||
"css": [
|
||||
"content-style.css"
|
||||
],
|
||||
"js": [
|
||||
"ryd.content-script.js"
|
||||
]
|
||||
}
|
||||
],
|
||||
"options_ui": {
|
||||
"page": "popup.html",
|
||||
"open_in_tab": false
|
||||
}
|
||||
// uncomment this section for local storage to work in firefox locally
|
||||
// "browser_specific_settings": {
|
||||
},
|
||||
"web_accessible_resources": [
|
||||
"menu-fixer.js"
|
||||
]
|
||||
|
||||
// uncomment this section for local storage to work in firefox locally,
|
||||
// ,"browser_specific_settings": {
|
||||
// "gecko": {
|
||||
// "id": "addon@example.com",
|
||||
// "strict_min_version": "42.0"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "__MSG_extensionName__",
|
||||
"description": "__MSG_extensionDesc__",
|
||||
"default_locale": "en",
|
||||
"version": "3.0.0.8",
|
||||
"version": "__RYD_VERSION__",
|
||||
"manifest_version": 2,
|
||||
"background": {
|
||||
"scripts": ["ryd.background.js"],
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
function debounceAsync(func, wait, renderer) {
|
||||
let timeout;
|
||||
let lastCallTime = 0;
|
||||
|
||||
return async function (...args) {
|
||||
const context = this;
|
||||
const now = Date.now();
|
||||
|
||||
if (!lastCallTime || now - lastCallTime > wait) {
|
||||
// If the last call was long enough ago or this is the first call, execute immediately
|
||||
lastCallTime = now;
|
||||
return await func.apply(context, args);
|
||||
} else {
|
||||
// Hide all optional menu items - prevents endless loop
|
||||
if (renderer?.polymerController?.flexAsTopLevelButtons) {
|
||||
renderer.polymerController.flexAsTopLevelButtons = [];
|
||||
}
|
||||
|
||||
// Otherwise, delay the call
|
||||
return new Promise((resolve) => {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(async () => {
|
||||
lastCallTime = Date.now();
|
||||
resolve(await func.apply(context, args));
|
||||
}, wait);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const fixYtdMenuRenderer = (ytdMenuRenderer) => {
|
||||
if (!ytdMenuRenderer?.polymerController?.maybeUpdateFlexibleMenuImpl) {
|
||||
return;
|
||||
}
|
||||
const originalMaybeUpdateFlexibleMenuImpl = ytdMenuRenderer.polymerController.maybeUpdateFlexibleMenuImpl.bind(
|
||||
ytdMenuRenderer.polymerController,
|
||||
);
|
||||
|
||||
ytdMenuRenderer.polymerController.maybeUpdateFlexibleMenuImpl = debounceAsync(
|
||||
originalMaybeUpdateFlexibleMenuImpl,
|
||||
100,
|
||||
ytdMenuRenderer,
|
||||
);
|
||||
};
|
||||
|
||||
const fixedYtdMenuRenderers = [];
|
||||
const observer = new MutationObserver(() => {
|
||||
const ytdMenuRenderers = [...document.querySelectorAll("ytd-menu-renderer")].filter(
|
||||
(el) => !fixedYtdMenuRenderers.includes(el),
|
||||
);
|
||||
if (!ytdMenuRenderers.length) return;
|
||||
|
||||
for (const el of ytdMenuRenderers) {
|
||||
fixYtdMenuRenderer(el);
|
||||
fixedYtdMenuRenderers.push(el);
|
||||
}
|
||||
});
|
||||
observer.observe(document.documentElement, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
});
|
||||
@@ -1,20 +1,52 @@
|
||||
/* Variables */
|
||||
:root {
|
||||
--primary: #cc2929;
|
||||
--accent: #581111;
|
||||
color-scheme: dark;
|
||||
|
||||
--background: #111;
|
||||
--secondary: #272727;
|
||||
--tertiary: #424242;
|
||||
--primary: #cc2929;
|
||||
--primary: #f39090;
|
||||
--secondary: #502e2e;
|
||||
--tertiary: #221818;
|
||||
--background: #352929;
|
||||
|
||||
--accent: #581111;
|
||||
--lightGrey: #999;
|
||||
--white: #fff;
|
||||
}
|
||||
|
||||
/*** MATERIAL 3 ***/
|
||||
.m3-primary {
|
||||
background: var(--primary) !important;
|
||||
color: var(--background) !important;
|
||||
}
|
||||
.m3-btn {
|
||||
background: var(--tertiary);
|
||||
color: var(--primary);
|
||||
transition: 0.4s;
|
||||
border-radius: 4px;
|
||||
font-weight: 500;
|
||||
border-radius: 100em;
|
||||
box-shadow: 0 5px 5px rgba(0,0,0,0.1);
|
||||
margin: 0.25em;
|
||||
}
|
||||
.m3-btn:hover {
|
||||
background: var(--secondary) !important;
|
||||
color: var(--primary) !important;
|
||||
}
|
||||
|
||||
select {
|
||||
border-radius: 1em;
|
||||
background-color: var(--secondary);
|
||||
color: var(--primary);
|
||||
border: none;
|
||||
outline: none;
|
||||
padding: 3px 2px;
|
||||
}
|
||||
/*** END MATERIAL 3 ***/
|
||||
|
||||
/* Window Styling */
|
||||
html,
|
||||
body {
|
||||
background-color: var(--background);
|
||||
color: var(--white);
|
||||
color: var(--primary);
|
||||
min-width: 310px;
|
||||
min-height: 350px;
|
||||
padding: 0.5em;
|
||||
@@ -26,30 +58,19 @@ h1 {
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
button {
|
||||
color: var(--white);
|
||||
background: var(--secondary);
|
||||
cursor: pointer;
|
||||
padding: 5px 16px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
font-weight: 500;
|
||||
/* box-shadow: 0 2px 4px -1px rgb(0 0 0 / 20%), 0 4px 5px 0 rgb(0 0 0 / 14%),
|
||||
0 1px 10px 0 rgb(0 0 0 / 12%); */
|
||||
transition: 0.4s;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background: #444;
|
||||
}
|
||||
|
||||
#ext-version {
|
||||
padding: 0.25rem 0.5rem;
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
padding: 5px 16px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#ext-update {
|
||||
cursor: pointer;
|
||||
color: var(--white);
|
||||
color: var(--primary);
|
||||
text-decoration: none;
|
||||
background: var(--primary);
|
||||
border-radius: 0.25rem;
|
||||
@@ -74,7 +95,9 @@ button:hover {
|
||||
content: attr(data-hover);
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
transition: visibility 0.1s linear, opacity 0.1s linear;
|
||||
transition:
|
||||
visibility 0.1s linear,
|
||||
opacity 0.1s linear;
|
||||
width: 250px;
|
||||
background-color: var(--secondary);
|
||||
border-radius: 0.5rem;
|
||||
@@ -113,17 +136,17 @@ button:hover {
|
||||
position: fixed;
|
||||
background: none;
|
||||
box-shadow: none;
|
||||
color: var(--lightGrey);
|
||||
color: var(--primary);
|
||||
top: 26px;
|
||||
right: 26px;
|
||||
padding: 2px;
|
||||
z-index: 69;
|
||||
height: 2rem;
|
||||
width: 2rem;
|
||||
transition-duration: .25s;
|
||||
}
|
||||
|
||||
#advancedToggle:hover {
|
||||
color: var(--white);
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
@@ -143,11 +166,10 @@ button:hover {
|
||||
right: 14px;
|
||||
width: calc(100% - 65px);
|
||||
height: calc(100% - 58px);
|
||||
border: 2px solid var(--secondary);
|
||||
border-radius: 0.5rem;
|
||||
padding: 1rem;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
border: none;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
@@ -159,7 +181,7 @@ button:hover {
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: #333; /* color of the scroll thumb */
|
||||
background-color: var(--primary); /* color of the scroll thumb */
|
||||
border-radius: 1rem 0 0 1rem; /* roundness of the scroll thumb */
|
||||
border-bottom: 0.25rem solid #111; /* creates padding around scroll thumb */
|
||||
border-left: 0.25rem solid #111; /* creates padding around scroll thumb */
|
||||
@@ -175,7 +197,7 @@ button:hover {
|
||||
}
|
||||
|
||||
#advancedLegend {
|
||||
color: var(--tertiary) !important;
|
||||
color: var(--secondary) !important;
|
||||
/* margin: auto; */ /* Center the label */
|
||||
/* padding: .25rem .5rem; */
|
||||
/* border-radius: .25rem; */
|
||||
@@ -226,7 +248,7 @@ button:hover {
|
||||
width: 13px;
|
||||
left: 2px;
|
||||
bottom: 2px;
|
||||
background: var(--lightGrey);
|
||||
background: var(--primary);
|
||||
transition: 0.4s;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<!--- HEADER -->
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" />
|
||||
<title title="__MSG_extensionName__">__MSG_extensionName__</title>
|
||||
@@ -11,15 +13,10 @@
|
||||
rel="stylesheet"
|
||||
/>
|
||||
</head>
|
||||
<!-- END HEADER -->
|
||||
<body>
|
||||
<center>
|
||||
<svg width="48" viewBox="0 0 24 24">
|
||||
<path
|
||||
d="M14.9 3H6c-.9 0-1.6.5-1.9 1.2l-3 7c-.1.3-.1.5-.1.7v2c0 1.1.9 2 2 2h6.3l-.9 4.5c-.1.5 0 1 .4 1.4l1.1 1.1 6.5-6.6c.4-.4.6-.9.6-1.4V5c-.1-1.1-1-2-2.1-2zm7.4 12.8h-2.9c-.4 0-.7-.3-.7-.7V3.9c0-.4.3-.7.7-.7h2.9c.4 0 .7.3.7.7V15c0 .4-.3.8-.7.8z"
|
||||
fill="red"
|
||||
/>
|
||||
<path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff" />
|
||||
</svg>
|
||||
<img src="icons/logo.svg" />
|
||||
<h1 style="margin-bottom: 0.75rem" title="__MSG_extensionName__">
|
||||
__MSG_extensionName__
|
||||
</h1>
|
||||
@@ -27,27 +24,29 @@
|
||||
__MSG_textDeveloper__
|
||||
</p>
|
||||
|
||||
<button id="link_website" title="__MSG_linkWebsite__">
|
||||
<button class="m3-btn" id="link_website" title="__MSG_linkWebsite__">
|
||||
__MSG_linkWebsite__
|
||||
</button>
|
||||
<button
|
||||
style="margin-top: 0.3em; background: #ff0000"
|
||||
class="m3-btn m3-primary"
|
||||
style="margin-top: 0.3em;"
|
||||
id="link_donate"
|
||||
title="__MSG_linkDonate__"
|
||||
>
|
||||
__MSG_linkDonate__
|
||||
</button>
|
||||
<button id="link_discord">Discord</button>
|
||||
<button class="m3-btn" id="link_discord">Discord</button>
|
||||
<br />
|
||||
<button style="margin-top: 0.3rem" id="link_faq" title="__MSG_linkFAQ__">
|
||||
<button class="m3-btn" style="margin-top: 0.3rem" id="link_faq" title="__MSG_linkFAQ__">
|
||||
__MSG_linkFAQ__
|
||||
</button>
|
||||
<button id="link_github">GitHub</button>
|
||||
<button style="margin-top: 0.3em" id="link_help" title="__MSG_linkHelp__">
|
||||
<button class="m3-btn" id="link_github">GitHub</button>
|
||||
<button class="m3-btn" style="margin-top: 0.3em" id="link_help" title="__MSG_linkHelp__">
|
||||
__MSG_linkHelp__
|
||||
</button>
|
||||
<br />
|
||||
<button
|
||||
class="m3-btn"
|
||||
style="margin-top: 0.3em"
|
||||
id="link_changelog"
|
||||
title="__MSG_linkChangelog__"
|
||||
@@ -85,7 +84,6 @@
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<!-- bottom-right -->
|
||||
<div id="ext">
|
||||
<a
|
||||
@@ -98,10 +96,12 @@
|
||||
|
||||
<!-- dialog box -->
|
||||
<fieldset id="advancedSettings">
|
||||
<legend id="advancedLegend" title="__MSG_legendSettings__">
|
||||
__MSG_legendSettings__
|
||||
</legend>
|
||||
|
||||
<label class="switch" data-hover="Disable Logging API Response in JavaScript Console.">
|
||||
<input type="checkbox" id="disable_logging"/>
|
||||
<span class="slider"/>
|
||||
<span class="switchLabel">Disable logging to console</span>
|
||||
</label>
|
||||
<br />
|
||||
<label class="switch" data-hover="Stop counting your likes and dislikes">
|
||||
<input type="checkbox" id="disable_vote_submission" />
|
||||
<span class="slider"></span>
|
||||
@@ -132,11 +132,14 @@
|
||||
<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>
|
||||
<span class="switchLabel">__MSG_colorizeThumbs__</span>
|
||||
</label>
|
||||
<br />
|
||||
<div class="custom-select">
|
||||
<label class="switch" data-hover="__MSG_colorizeThumbsHover__">
|
||||
<input type="checkbox" id="colored_thumbs" />
|
||||
<span class="slider"></span>
|
||||
<span class="switchLabel">__MSG_colorizeThumbs__</span>
|
||||
</label>
|
||||
</div>
|
||||
<br />
|
||||
<div class="custom-select">
|
||||
<label for="color_theme">__MSG_colorTheme__</label>
|
||||
@@ -175,17 +178,17 @@
|
||||
<br />
|
||||
<label
|
||||
class="switch"
|
||||
data-hover="Display percentage in like/dislike bar tooltip."
|
||||
data-hover="__MSG_showTooltipPercentageHover__"
|
||||
>
|
||||
<input type="checkbox" id="show_tooltip_percentage" />
|
||||
<span class="slider"></span>
|
||||
<span class="switchLabel">Percentage in like/dislike bar tooltip.</span>
|
||||
<span class="switchLabel">__MSG_showTooltipPercentage__</span>
|
||||
</label>
|
||||
<div class="custom-select">
|
||||
<label
|
||||
for="tooltip_percentage_mode"
|
||||
data-hover="Use custom percentage display on hover."
|
||||
>Percent mode:</label
|
||||
data-hover="__MSG_tooltipPercentageModeHover__"
|
||||
>__MSG_tooltipPercentageMode__</label
|
||||
>
|
||||
<select name="tooltip_percentage_mode" id="tooltip_percentage_mode">
|
||||
<option value="dash_like" id="tooltip_percentage_mode_dash_like">
|
||||
|
||||
@@ -4,6 +4,7 @@ import { cLog } from "./src/utils";
|
||||
const config = {
|
||||
advanced: false,
|
||||
disableVoteSubmission: false,
|
||||
disableLogging: true,
|
||||
coloredThumbs: false,
|
||||
coloredBar: false,
|
||||
colorTheme: "classic",
|
||||
@@ -15,7 +16,6 @@ const config = {
|
||||
'<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",
|
||||
github: "https://github.com/Anarios/return-youtube-dislike",
|
||||
@@ -68,6 +68,10 @@ document
|
||||
chrome.storage.sync.set({ disableVoteSubmission: ev.target.checked });
|
||||
});
|
||||
|
||||
document.getElementById("disable_logging").addEventListener("click", (ev) => {
|
||||
chrome.storage.sync.set({ disableLogging:ev.target.checked })
|
||||
});
|
||||
|
||||
document.getElementById("colored_thumbs").addEventListener("click", (ev) => {
|
||||
chrome.storage.sync.set({ coloredThumbs: ev.target.checked });
|
||||
});
|
||||
@@ -80,7 +84,6 @@ document.getElementById("color_theme").addEventListener("click", (ev) => {
|
||||
chrome.storage.sync.set({ colorTheme: ev.target.value });
|
||||
});
|
||||
|
||||
|
||||
document.getElementById("number_format").addEventListener("change", (ev) => {
|
||||
chrome.storage.sync.set({ numberDisplayFormat: ev.target.value });
|
||||
});
|
||||
@@ -125,6 +128,7 @@ initConfig();
|
||||
|
||||
function initConfig() {
|
||||
initializeDisableVoteSubmission();
|
||||
initializeDisableLogging();
|
||||
initializeVersionNumber();
|
||||
initializeColoredThumbs();
|
||||
initializeColoredBar();
|
||||
@@ -140,7 +144,7 @@ function initializeVersionNumber() {
|
||||
document.getElementById("ext-version").innerHTML = "v" + version;
|
||||
|
||||
fetch(
|
||||
"https://raw.githubusercontent.com/Anarios/return-youtube-dislike/main/Extensions/combined/manifest-chrome.json"
|
||||
"https://raw.githubusercontent.com/Anarios/return-youtube-dislike/main/Extensions/combined/manifest-chrome.json",
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
@@ -179,6 +183,12 @@ function initializeDisableVoteSubmission() {
|
||||
});
|
||||
}
|
||||
|
||||
function initializeDisableLogging(){
|
||||
chrome.storage.sync.get(['disableLogging'], (res) => {
|
||||
handleDisableLoggingChangeEvent(res.disableLogging);
|
||||
});
|
||||
}
|
||||
|
||||
function initializeColoredThumbs() {
|
||||
chrome.storage.sync.get(["coloredThumbs"], (res) => {
|
||||
handleColoredThumbsChangeEvent(res.coloredThumbs);
|
||||
@@ -197,7 +207,6 @@ function initializeColorTheme() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function initializeTooltipPercentage() {
|
||||
chrome.storage.sync.get(["showTooltipPercentage"], (res) => {
|
||||
handleShowTooltipPercentageChangeEvent(res.showTooltipPercentage);
|
||||
@@ -238,9 +247,12 @@ chrome.storage.onChanged.addListener(storageChangeHandler);
|
||||
function storageChangeHandler(changes, area) {
|
||||
if (changes.disableVoteSubmission !== undefined) {
|
||||
handleDisableVoteSubmissionChangeEvent(
|
||||
changes.disableVoteSubmission.newValue
|
||||
changes.disableVoteSubmission.newValue,
|
||||
);
|
||||
}
|
||||
if (changes.disableLogging !== undefined) {
|
||||
handleDisableLoggingChangeEvent(changes.disableLogging.newValue);
|
||||
}
|
||||
if (changes.coloredThumbs !== undefined) {
|
||||
handleColoredThumbsChangeEvent(changes.coloredThumbs.newValue);
|
||||
}
|
||||
@@ -255,12 +267,12 @@ function storageChangeHandler(changes, area) {
|
||||
}
|
||||
if (changes.showTooltipPercentage !== undefined) {
|
||||
handleShowTooltipPercentageChangeEvent(
|
||||
changes.showTooltipPercentage.newValue
|
||||
changes.showTooltipPercentage.newValue,
|
||||
);
|
||||
}
|
||||
if (changes.numberDisplayReformatLikes !== undefined) {
|
||||
handleNumberDisplayReformatLikesChangeEvent(
|
||||
changes.numberDisplayReformatLikes.newValue
|
||||
changes.numberDisplayReformatLikes.newValue,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -270,6 +282,11 @@ function handleDisableVoteSubmissionChangeEvent(value) {
|
||||
document.getElementById("disable_vote_submission").checked = value;
|
||||
}
|
||||
|
||||
function handleDisableLoggingChangeEvent(value) {
|
||||
config.disableLogging = value;
|
||||
document.getElementById("disable_logging").checked = value;
|
||||
}
|
||||
|
||||
function handleColoredThumbsChangeEvent(value) {
|
||||
config.coloredThumbs = value;
|
||||
document.getElementById("colored_thumbs").checked = value;
|
||||
@@ -298,8 +315,6 @@ function updateColorThemePreviewContent(themeName) {
|
||||
getColorFromTheme(themeName, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function handleNumberDisplayFormatChangeEvent(value) {
|
||||
config.numberDisplayFormat = value;
|
||||
document
|
||||
@@ -336,7 +351,7 @@ function getNumberFormatter(optionSelect) {
|
||||
userLocales = new URL(
|
||||
Array.from(document.querySelectorAll("head > link[rel='search']"))
|
||||
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
|
||||
?.getAttribute("href")
|
||||
?.getAttribute("href"),
|
||||
)?.searchParams?.get("locale");
|
||||
} catch {}
|
||||
|
||||
@@ -359,7 +374,7 @@ function getNumberFormatter(optionSelect) {
|
||||
{
|
||||
notation: formatterNotation,
|
||||
compactDisplay: formatterCompactDisplay,
|
||||
}
|
||||
},
|
||||
);
|
||||
return formatter;
|
||||
}
|
||||
@@ -368,7 +383,7 @@ function getNumberFormatter(optionSelect) {
|
||||
let status = document.getElementById("status");
|
||||
let serverStatus = document.getElementById("server-status");
|
||||
let resp = await fetch(
|
||||
"https://returnyoutubedislikeapi.com/votes?videoId=YbJOTdZBX1g"
|
||||
"https://returnyoutubedislikeapi.com/votes?videoId=YbJOTdZBX1g",
|
||||
);
|
||||
let result = await resp.status;
|
||||
if (result === 200) {
|
||||
|
||||
@@ -6,6 +6,7 @@ let api;
|
||||
/** stores extension's global config */
|
||||
let extConfig = {
|
||||
disableVoteSubmission: false,
|
||||
disableLogging: true,
|
||||
coloredThumbs: false,
|
||||
coloredBar: false,
|
||||
colorTheme: "classic", // classic, accessible, neon
|
||||
@@ -31,17 +32,12 @@ api.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
} else if (request.message == "set_state") {
|
||||
// chrome.identity.getAuthToken({ interactive: true }, function (token) {
|
||||
let token = "";
|
||||
fetch(
|
||||
`${apiUrl}/votes?videoId=${request.videoId}&likeCount=${
|
||||
request.likeCount || ""
|
||||
}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
}
|
||||
)
|
||||
fetch(`${apiUrl}/votes?videoId=${request.videoId}&likeCount=${request.likeCount || ""}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((response) => {
|
||||
sendResponse(response);
|
||||
@@ -100,7 +96,7 @@ api.runtime.onInstalled.addListener((details) => {
|
||||
// }
|
||||
// });
|
||||
|
||||
async function sendVote(videoId, vote) {
|
||||
async function sendVote(videoId, vote, depth = 1) {
|
||||
api.storage.sync.get(null, async (storageResult) => {
|
||||
if (!storageResult.userId || !storageResult.registrationConfirmed) {
|
||||
await register();
|
||||
@@ -117,11 +113,14 @@ async function sendVote(videoId, vote) {
|
||||
}),
|
||||
});
|
||||
|
||||
if (voteResponse.status == 401) {
|
||||
if (voteResponse.status == 401 && depth > 0) {
|
||||
await register();
|
||||
await sendVote(videoId, vote);
|
||||
await sendVote(videoId, vote, depth-1);
|
||||
return;
|
||||
} else if (voteResponse.status == 401) { // We have already tried registering
|
||||
return;
|
||||
}
|
||||
|
||||
const voteResponseJson = await voteResponse.json();
|
||||
const solvedPuzzle = await solvePuzzle(voteResponseJson);
|
||||
if (!solvedPuzzle.solution) {
|
||||
@@ -146,15 +145,12 @@ async function sendVote(videoId, vote) {
|
||||
async function register() {
|
||||
const userId = generateUserID();
|
||||
api.storage.sync.set({ userId });
|
||||
const registrationResponse = await fetch(
|
||||
`${apiUrl}/puzzle/registration?userId=${userId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
}
|
||||
).then((response) => response.json());
|
||||
const registrationResponse = await fetch(`${apiUrl}/puzzle/registration?userId=${userId}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
}).then((response) => response.json());
|
||||
const solvedPuzzle = await solvePuzzle(registrationResponse);
|
||||
if (!solvedPuzzle.solution) {
|
||||
await register();
|
||||
@@ -209,9 +205,7 @@ function countLeadingZeroes(uInt8View, limit) {
|
||||
}
|
||||
|
||||
async function solvePuzzle(puzzle) {
|
||||
let challenge = Uint8Array.from(atob(puzzle.challenge), (c) =>
|
||||
c.charCodeAt(0)
|
||||
);
|
||||
let challenge = Uint8Array.from(atob(puzzle.challenge), (c) => c.charCodeAt(0));
|
||||
let buffer = new ArrayBuffer(20);
|
||||
let uInt8View = new Uint8Array(buffer);
|
||||
let uInt32View = new Uint32Array(buffer);
|
||||
@@ -234,8 +228,7 @@ async function solvePuzzle(puzzle) {
|
||||
}
|
||||
|
||||
function generateUserID(length = 36) {
|
||||
const charset =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
let result = "";
|
||||
if (crypto && crypto.getRandomValues) {
|
||||
const values = new Uint32Array(length);
|
||||
@@ -254,9 +247,7 @@ function generateUserID(length = 36) {
|
||||
|
||||
function storageChangeHandler(changes, area) {
|
||||
if (changes.disableVoteSubmission !== undefined) {
|
||||
handleDisableVoteSubmissionChangeEvent(
|
||||
changes.disableVoteSubmission.newValue
|
||||
);
|
||||
handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue);
|
||||
}
|
||||
if (changes.coloredThumbs !== undefined) {
|
||||
handleColoredThumbsChangeEvent(changes.coloredThumbs.newValue);
|
||||
@@ -271,19 +262,16 @@ function storageChangeHandler(changes, area) {
|
||||
handleNumberDisplayFormatChangeEvent(changes.numberDisplayFormat.newValue);
|
||||
}
|
||||
if (changes.numberDisplayReformatLikes !== undefined) {
|
||||
handleNumberDisplayReformatLikesChangeEvent(
|
||||
changes.numberDisplayReformatLikes.newValue
|
||||
);
|
||||
handleNumberDisplayReformatLikesChangeEvent(changes.numberDisplayReformatLikes.newValue);
|
||||
}
|
||||
if (changes.disableLogging !== undefined) {
|
||||
handleDisableLoggingChangeEvent(changes.disableLogging.newValue);
|
||||
}
|
||||
if (changes.showTooltipPercentage !== undefined) {
|
||||
handleShowTooltipPercentageChangeEvent(
|
||||
changes.showTooltipPercentage.newValue
|
||||
);
|
||||
handleShowTooltipPercentageChangeEvent(changes.showTooltipPercentage.newValue);
|
||||
}
|
||||
if (changes.numberDisplayReformatLikes !== undefined) {
|
||||
handleNumberDisplayReformatLikesChangeEvent(
|
||||
changes.numberDisplayReformatLikes.newValue
|
||||
);
|
||||
handleNumberDisplayReformatLikesChangeEvent(changes.numberDisplayReformatLikes.newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,6 +284,10 @@ function handleDisableVoteSubmissionChangeEvent(value) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleDisableLoggingChangeEvent(value) {
|
||||
extConfig.disableLogging = value;
|
||||
}
|
||||
|
||||
function handleNumberDisplayFormatChangeEvent(value) {
|
||||
extConfig.numberDisplayFormat = value;
|
||||
}
|
||||
@@ -312,10 +304,8 @@ function handleTooltipPercentageModeChangeEvent(value) {
|
||||
}
|
||||
|
||||
function changeIcon(iconName) {
|
||||
if (api.action !== undefined)
|
||||
api.action.setIcon({ path: "/icons/" + iconName });
|
||||
else if (api.browserAction !== undefined)
|
||||
api.browserAction.setIcon({ path: "/icons/" + iconName });
|
||||
if (api.action !== undefined) api.action.setIcon({ path: "/icons/" + iconName });
|
||||
else if (api.browserAction !== undefined) api.browserAction.setIcon({ path: "/icons/" + iconName });
|
||||
else console.log("changing icon is not supported");
|
||||
}
|
||||
|
||||
@@ -342,6 +332,7 @@ api.storage.onChanged.addListener(storageChangeHandler);
|
||||
|
||||
function initExtConfig() {
|
||||
initializeDisableVoteSubmission();
|
||||
initializeDisableLogging();
|
||||
initializeColoredThumbs();
|
||||
initializeColoredBar();
|
||||
initializeColorTheme();
|
||||
@@ -362,6 +353,16 @@ function initializeDisableVoteSubmission() {
|
||||
});
|
||||
}
|
||||
|
||||
function initializeDisableLogging() {
|
||||
api.storage.sync.get(["disableLogging"], (res) => {
|
||||
if (res.disableLogging === undefined) {
|
||||
api.storage.sync.set({ disableLogging: true });
|
||||
} else {
|
||||
extConfig.disableLogging = res.disableLogging;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initializeColoredThumbs() {
|
||||
api.storage.sync.get(["coloredThumbs"], (res) => {
|
||||
if (res.coloredThumbs === undefined) {
|
||||
@@ -437,7 +438,5 @@ function isChrome() {
|
||||
}
|
||||
|
||||
function isFirefox() {
|
||||
return (
|
||||
typeof browser !== "undefined" && typeof browser.runtime !== "undefined"
|
||||
);
|
||||
return typeof browser !== "undefined" && typeof browser.runtime !== "undefined";
|
||||
}
|
||||
@@ -1,77 +1,53 @@
|
||||
//--- Import Button Functions ---//
|
||||
import {
|
||||
getButtons,
|
||||
getLikeButton,
|
||||
getDislikeButton,
|
||||
checkForSignInButton,
|
||||
} from "./src/buttons";
|
||||
import { getButtons } from "./src/buttons";
|
||||
|
||||
//--- Import State Functions ---//
|
||||
import {
|
||||
isMobile,
|
||||
isShorts,
|
||||
isVideoDisliked,
|
||||
isVideoLiked,
|
||||
getState,
|
||||
setState,
|
||||
setInitialState,
|
||||
setLikes,
|
||||
setDislikes,
|
||||
getLikeCountFromButton,
|
||||
LIKED_STATE,
|
||||
DISLIKED_STATE,
|
||||
NEUTRAL_STATE,
|
||||
initExtConfig,
|
||||
} from "./src/state";
|
||||
import { isShorts, setInitialState, initExtConfig } from "./src/state";
|
||||
|
||||
//--- Import Video & Browser Functions ---//
|
||||
import {
|
||||
numberFormat,
|
||||
getBrowser,
|
||||
getVideoId,
|
||||
isVideoLoaded,
|
||||
cLog,
|
||||
} from "./src/utils";
|
||||
import { createRateBar } from "./src/bar";
|
||||
import {
|
||||
sendVote,
|
||||
likeClicked,
|
||||
dislikeClicked,
|
||||
addLikeDislikeEventListener,
|
||||
storageChangeHandler,
|
||||
} from "./src/events";
|
||||
import { getBrowser, isVideoLoaded, cLog } from "./src/utils";
|
||||
import { addLikeDislikeEventListener, createSmartimationObserver, storageChangeHandler } from "./src/events";
|
||||
|
||||
initExtConfig();
|
||||
await initExtConfig();
|
||||
|
||||
let jsInitChecktimer = null;
|
||||
let isSetInitialStateDone = false;
|
||||
|
||||
function setEventListeners(evt) {
|
||||
function checkForJS_Finish() {
|
||||
async function setEventListeners(evt) {
|
||||
async function checkForJS_Finish() {
|
||||
try {
|
||||
if (isShorts() || (getButtons()?.offsetParent && isVideoLoaded())) {
|
||||
addLikeDislikeEventListener();
|
||||
setInitialState();
|
||||
isSetInitialStateDone = true;
|
||||
getBrowser().storage.onChanged.addListener(storageChangeHandler);
|
||||
clearInterval(jsInitChecktimer);
|
||||
jsInitChecktimer = null;
|
||||
}
|
||||
} catch(exception) {
|
||||
if(!isSetInitialStateDone) {
|
||||
setInitialState();
|
||||
createSmartimationObserver();
|
||||
addLikeDislikeEventListener();
|
||||
await setInitialState();
|
||||
isSetInitialStateDone = true;
|
||||
getBrowser().storage.onChanged.addListener(storageChangeHandler);
|
||||
}
|
||||
} catch (exception) {
|
||||
if (!isSetInitialStateDone) {
|
||||
cLog("error");
|
||||
await setInitialState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
jsInitChecktimer = setInterval(checkForJS_Finish, 111);
|
||||
if (jsInitChecktimer !== null) clearInterval(jsInitChecktimer);
|
||||
jsInitChecktimer = setInterval(await checkForJS_Finish, 111);
|
||||
}
|
||||
|
||||
setEventListeners();
|
||||
await setEventListeners();
|
||||
|
||||
document.addEventListener("yt-navigate-finish", function (event) {
|
||||
document.addEventListener("yt-navigate-finish", async function (event) {
|
||||
if (jsInitChecktimer !== null) clearInterval(jsInitChecktimer);
|
||||
window.returnDislikeButtonlistenersSet = false;
|
||||
setEventListeners();
|
||||
await setEventListeners();
|
||||
});
|
||||
|
||||
const s = document.createElement("script");
|
||||
s.src = chrome.runtime.getURL("menu-fixer.js");
|
||||
s.onload = function () {
|
||||
this.remove();
|
||||
};
|
||||
// see also "Dynamic values in the injected code" section in this answer
|
||||
(document.head || document.documentElement).appendChild(s);
|
||||
@@ -0,0 +1,15 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`getNumberFormatter should return a correct formatter when falling back to default locale 1`] = `NumberFormat {}`;
|
||||
|
||||
exports[`getNumberFormatter should return a correct formatter when using chrome 1`] = `NumberFormat {}`;
|
||||
|
||||
exports[`getNumberFormatter should return a correct formatter when using firefox 1`] = `NumberFormat {}`;
|
||||
|
||||
exports[`getNumberFormatter should return a correct formatter when using the URL locale (possibly buggy) 1`] = `NumberFormat {}`;
|
||||
|
||||
exports[`getNumberFormatter should return a correct formatter when using the URL locale 1`] = `NumberFormat {}`;
|
||||
|
||||
exports[`getNumberFormatter should return a correct formatter whith standard option 1`] = `NumberFormat {}`;
|
||||
|
||||
exports[`getNumberFormatter should return a correct formatter with compactLong option 1`] = `NumberFormat {}`;
|
||||
@@ -13,14 +13,14 @@ function createRateBar(likes, dislikes) {
|
||||
let rateBar = document.getElementById("ryd-bar-container");
|
||||
if (!isLikesDisabled()) {
|
||||
// sometimes rate bar is hidden
|
||||
if(rateBar && !isInViewport(rateBar)){
|
||||
if (rateBar && !isInViewport(rateBar)) {
|
||||
rateBar.remove();
|
||||
rateBar = null;
|
||||
}
|
||||
|
||||
const widthPx =
|
||||
getLikeButton().clientWidth +
|
||||
getDislikeButton().clientWidth +
|
||||
parseFloat(window.getComputedStyle(getLikeButton()).width) +
|
||||
parseFloat(window.getComputedStyle(getDislikeButton()).width) +
|
||||
(isRoundedDesign() ? 0 : 8);
|
||||
|
||||
const widthPercent =
|
||||
@@ -60,10 +60,13 @@ function createRateBar(likes, dislikes) {
|
||||
colorLikeStyle = "; background-color: " + getColorFromTheme(true);
|
||||
colorDislikeStyle = "; background-color: " + getColorFromTheme(false);
|
||||
}
|
||||
let actions = isNewDesign() && getButtons().id === "top-level-buttons-computed"
|
||||
? getButtons() : document.getElementById("menu-container");
|
||||
let actions =
|
||||
isNewDesign() && getButtons().id === "top-level-buttons-computed"
|
||||
? getButtons()
|
||||
: document.getElementById("menu-container");
|
||||
(
|
||||
actions || document.querySelector("ytm-slim-video-action-bar-renderer")
|
||||
actions ||
|
||||
document.querySelector("ytm-slim-video-action-bar-renderer")
|
||||
).insertAdjacentHTML(
|
||||
"beforeend",
|
||||
`
|
||||
@@ -83,7 +86,7 @@ function createRateBar(likes, dislikes) {
|
||||
<!--css-build:shady-->${tooltipInnerHTML}
|
||||
</tp-yt-paper-tooltip>
|
||||
</div>
|
||||
`
|
||||
`,
|
||||
);
|
||||
|
||||
if (isNewDesign()) {
|
||||
@@ -101,8 +104,7 @@ function createRateBar(likes, dislikes) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
document.getElementById("ryd-bar-container").style.width =
|
||||
widthPx + "px";
|
||||
document.querySelector(`.ryd-tooltip`).style.width = widthPx + "px";
|
||||
document.getElementById("ryd-bar").style.width = widthPercent + "%";
|
||||
document.querySelector("#ryd-dislike-tooltip > #tooltip").innerHTML =
|
||||
tooltipInnerHTML;
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import { isMobile, isShorts } from "./state";
|
||||
import { isInViewport } from "./utils";
|
||||
import { isMobile, isShorts, extConfig } from "./state";
|
||||
import { isInViewport, querySelector, querySelectorAll } from "./utils";
|
||||
|
||||
function getButtons() {
|
||||
//--- If Watching Youtube Shorts: ---//
|
||||
if (isShorts()) {
|
||||
let elements = document.querySelectorAll(
|
||||
isMobile()
|
||||
? "ytm-like-button-renderer"
|
||||
: "#like-button > ytd-like-button-renderer"
|
||||
);
|
||||
let elements = isMobile()
|
||||
? querySelectorAll(extConfig.selectors.buttons.shorts.mobile)
|
||||
: querySelectorAll(extConfig.selectors.buttons.shorts.desktop);
|
||||
|
||||
for (let element of elements) {
|
||||
//Youtube Shorts can have multiple like/dislike buttons when scrolling through videos
|
||||
//YouTube Shorts can have multiple like/dislike buttons when scrolling through videos
|
||||
//However, only one of them should be visible (no matter how you zoom)
|
||||
if (isInViewport(element)) {
|
||||
return element;
|
||||
@@ -19,73 +18,92 @@ function getButtons() {
|
||||
}
|
||||
//--- If Watching On Mobile: ---//
|
||||
if (isMobile()) {
|
||||
return document.querySelector(".slim-video-action-bar-actions");
|
||||
return document.querySelector(extConfig.selectors.buttons.regular.mobile);
|
||||
}
|
||||
//--- If Menu Element Is Displayed: ---//
|
||||
if (document.getElementById("menu-container")?.offsetParent === null) {
|
||||
return document.querySelector("ytd-menu-renderer.ytd-watch-metadata > div");
|
||||
if (querySelector(extConfig.selectors.menuContainer)?.offsetParent === null) {
|
||||
return querySelector(extConfig.selectors.buttons.regular.desktopMenu);
|
||||
//--- If Menu Element Isn't Displayed: ---//
|
||||
} else {
|
||||
return document
|
||||
.getElementById("menu-container")
|
||||
?.querySelector("#top-level-buttons-computed");
|
||||
return querySelector(extConfig.selectors.buttons.regular.desktopNoMenu);
|
||||
}
|
||||
}
|
||||
|
||||
function getLikeButton() {
|
||||
return getButtons().children[0].tagName ===
|
||||
"YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER"
|
||||
? document.querySelector("#segmented-like-button") !== null ? document.querySelector("#segmented-like-button") : getButtons().children[0].children[0]
|
||||
: getButtons().querySelector("like-button-view-model") ?? getButtons().children[0];
|
||||
? querySelector(extConfig.selectors.buttons.likeButton.segmented) ??
|
||||
querySelector(
|
||||
extConfig.selectors.buttons.likeButton.segmentedGetButtons,
|
||||
getButtons(),
|
||||
)
|
||||
: querySelector(
|
||||
extConfig.selectors.buttons.likeButton.notSegmented,
|
||||
getButtons(),
|
||||
);
|
||||
}
|
||||
|
||||
function getLikeTextContainer() {
|
||||
return (
|
||||
getLikeButton().querySelector("#text") ??
|
||||
getLikeButton().getElementsByTagName("yt-formatted-string")[0] ??
|
||||
getLikeButton().querySelector("span[role='text']")
|
||||
);
|
||||
return querySelector(extConfig.selectors.likeTextContainer, getLikeButton());
|
||||
}
|
||||
|
||||
function getDislikeButton() {
|
||||
if (getButtons().children[0].tagName === 'YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER') {
|
||||
if (getButtons().children[0].children[1] === undefined) {
|
||||
return document.querySelector('#segmented-dislike-button');
|
||||
} else {
|
||||
return getButtons().children[0].children[1];
|
||||
}
|
||||
} else {
|
||||
if (getButtons().querySelector("dislike-button-view-model")) {
|
||||
return getButtons().querySelector("dislike-button-view-model");
|
||||
} else {
|
||||
return getButtons().children[1];
|
||||
}
|
||||
}
|
||||
return getButtons().children[0].tagName ===
|
||||
"YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER"
|
||||
? querySelector(extConfig.selectors.buttons.dislikeButton.segmented) ??
|
||||
querySelector(
|
||||
extConfig.selectors.buttons.dislikeButton.segmentedGetButtons,
|
||||
getButtons(),
|
||||
)
|
||||
: isShorts()
|
||||
? querySelector(["#dislike-button"], getButtons())
|
||||
: querySelector(
|
||||
extConfig.selectors.buttons.dislikeButton.notSegmented,
|
||||
getButtons(),
|
||||
);
|
||||
}
|
||||
|
||||
function createDislikeTextContainer() {
|
||||
const textNodeClone = (getLikeButton().querySelector("button > div[class*='cbox']") || (getLikeButton().querySelector('div > span[role="text"]') || document.querySelector('button > div.yt-spec-button-shape-next__button-text-content > span[role="text"]')).parentNode).cloneNode(true);
|
||||
const insertPreChild = getDislikeButton().querySelector("yt-touch-feedback-shape");
|
||||
getDislikeButton().querySelector("button").insertBefore(textNodeClone, insertPreChild);
|
||||
getDislikeButton().querySelector("button").classList.remove("yt-spec-button-shape-next--icon-button");
|
||||
getDislikeButton().querySelector("button").classList.add("yt-spec-button-shape-next--icon-leading");
|
||||
if(textNodeClone.querySelector("span[role='text']") === null) {
|
||||
const textNodeClone = (
|
||||
getLikeButton().querySelector(
|
||||
".yt-spec-button-shape-next__button-text-content",
|
||||
) ||
|
||||
getLikeButton().querySelector("button > div[class*='cbox']") ||
|
||||
(
|
||||
getLikeButton().querySelector('div > span[role="text"]') ||
|
||||
document.querySelector(
|
||||
'button > div.yt-spec-button-shape-next__button-text-content > span[role="text"]',
|
||||
)
|
||||
).parentNode
|
||||
).cloneNode(true);
|
||||
const insertPreChild = getDislikeButton().querySelector("button");
|
||||
insertPreChild.insertBefore(textNodeClone, null);
|
||||
getDislikeButton()
|
||||
.querySelector("button")
|
||||
.classList.remove("yt-spec-button-shape-next--icon-button");
|
||||
getDislikeButton()
|
||||
.querySelector("button")
|
||||
.classList.add("yt-spec-button-shape-next--icon-leading");
|
||||
if (textNodeClone.querySelector("span[role='text']") === null) {
|
||||
const span = document.createElement("span");
|
||||
span.setAttribute("role", "text");
|
||||
while(textNodeClone.firstChild){
|
||||
while (textNodeClone.firstChild) {
|
||||
textNodeClone.removeChild(textNodeClone.firstChild);
|
||||
}
|
||||
textNodeClone.appendChild(span);
|
||||
}
|
||||
textNodeClone.querySelector("span[role='text']").innerText = "";
|
||||
return textNodeClone.querySelector("span[role='text']");
|
||||
textNodeClone.innerText = "";
|
||||
return textNodeClone;
|
||||
}
|
||||
|
||||
function getDislikeTextContainer() {
|
||||
let result =
|
||||
getDislikeButton().querySelector("#text") ??
|
||||
getDislikeButton().getElementsByTagName("yt-formatted-string")[0] ??
|
||||
getDislikeButton().querySelector("span[role='text']");
|
||||
let result;
|
||||
for (const selector of extConfig.selectors.dislikeTextContainer) {
|
||||
result = getDislikeButton().querySelector(selector);
|
||||
if (result !== null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (result == null) {
|
||||
result = createDislikeTextContainer();
|
||||
}
|
||||
@@ -95,7 +113,7 @@ function getDislikeTextContainer() {
|
||||
function checkForSignInButton() {
|
||||
if (
|
||||
document.querySelector(
|
||||
"a[href^='https://accounts.google.com/ServiceLogin']"
|
||||
"a[href^='https://accounts.google.com/ServiceLogin']",
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import { getBrowser, getVideoId, numberFormat, cLog } from "./utils";
|
||||
import { checkForSignInButton, getButtons, getDislikeButton, getLikeButton } from './buttons';
|
||||
import {
|
||||
getBrowser,
|
||||
getVideoId,
|
||||
numberFormat,
|
||||
cLog,
|
||||
createObserver,
|
||||
} from "./utils";
|
||||
import {
|
||||
checkForSignInButton,
|
||||
getButtons,
|
||||
getDislikeButton,
|
||||
getLikeButton,
|
||||
} from "./buttons";
|
||||
import {
|
||||
NEUTRAL_STATE,
|
||||
LIKED_STATE,
|
||||
@@ -22,24 +33,28 @@ function sendVote(vote) {
|
||||
}
|
||||
}
|
||||
|
||||
function updateDOMDislikes() {
|
||||
setDislikes(numberFormat(storedData.dislikes));
|
||||
createRateBar(storedData.likes, storedData.dislikes);
|
||||
}
|
||||
|
||||
function likeClicked() {
|
||||
if (checkForSignInButton() === false) {
|
||||
if (storedData.previousState === DISLIKED_STATE) {
|
||||
sendVote(1);
|
||||
if (storedData.dislikes > 0) storedData.dislikes--;
|
||||
storedData.likes++;
|
||||
createRateBar(storedData.likes, storedData.dislikes);
|
||||
setDislikes(numberFormat(storedData.dislikes));
|
||||
updateDOMDislikes();
|
||||
storedData.previousState = LIKED_STATE;
|
||||
} else if (storedData.previousState === NEUTRAL_STATE) {
|
||||
sendVote(1);
|
||||
storedData.likes++;
|
||||
createRateBar(storedData.likes, storedData.dislikes);
|
||||
updateDOMDislikes();
|
||||
storedData.previousState = LIKED_STATE;
|
||||
} else if ((storedData.previousState = LIKED_STATE)) {
|
||||
sendVote(0);
|
||||
if (storedData.likes > 0) storedData.likes--;
|
||||
createRateBar(storedData.likes, storedData.dislikes);
|
||||
updateDOMDislikes();
|
||||
storedData.previousState = NEUTRAL_STATE;
|
||||
}
|
||||
if (extConfig.numberDisplayReformatLikes === true) {
|
||||
@@ -56,21 +71,18 @@ function dislikeClicked() {
|
||||
if (storedData.previousState === NEUTRAL_STATE) {
|
||||
sendVote(-1);
|
||||
storedData.dislikes++;
|
||||
setDislikes(numberFormat(storedData.dislikes));
|
||||
createRateBar(storedData.likes, storedData.dislikes);
|
||||
updateDOMDislikes();
|
||||
storedData.previousState = DISLIKED_STATE;
|
||||
} else if (storedData.previousState === DISLIKED_STATE) {
|
||||
sendVote(0);
|
||||
if (storedData.dislikes > 0) storedData.dislikes--;
|
||||
setDislikes(numberFormat(storedData.dislikes));
|
||||
createRateBar(storedData.likes, storedData.dislikes);
|
||||
updateDOMDislikes();
|
||||
storedData.previousState = NEUTRAL_STATE;
|
||||
} else if (storedData.previousState === LIKED_STATE) {
|
||||
sendVote(-1);
|
||||
if (storedData.likes > 0) storedData.likes--;
|
||||
storedData.dislikes++;
|
||||
setDislikes(numberFormat(storedData.dislikes));
|
||||
createRateBar(storedData.likes, storedData.dislikes);
|
||||
updateDOMDislikes();
|
||||
storedData.previousState = DISLIKED_STATE;
|
||||
if (extConfig.numberDisplayReformatLikes === true) {
|
||||
const nativeLikes = getLikeCountFromButton();
|
||||
@@ -83,21 +95,50 @@ function dislikeClicked() {
|
||||
}
|
||||
|
||||
function addLikeDislikeEventListener() {
|
||||
if (!window.returnDislikeButtonlistenersSet) {
|
||||
if (window.rydPreNavigateLikeButton !== getLikeButton()) {
|
||||
getLikeButton().addEventListener("click", likeClicked);
|
||||
getLikeButton().addEventListener("touchstart", likeClicked);
|
||||
if(getDislikeButton()) {
|
||||
if (getDislikeButton()) {
|
||||
getDislikeButton().addEventListener("click", dislikeClicked);
|
||||
getDislikeButton().addEventListener("touchstart", dislikeClicked);
|
||||
getDislikeButton().addEventListener("focusin", updateDOMDislikes);
|
||||
getDislikeButton().addEventListener("focusout", updateDOMDislikes);
|
||||
}
|
||||
window.returnDislikeButtonlistenersSet = true;
|
||||
window.rydPreNavigateLikeButton = getLikeButton();
|
||||
}
|
||||
}
|
||||
|
||||
let smartimationObserver = null;
|
||||
|
||||
function createSmartimationObserver() {
|
||||
if (!smartimationObserver) {
|
||||
smartimationObserver = createObserver(
|
||||
{
|
||||
attributes: true,
|
||||
subtree: true,
|
||||
childList: true,
|
||||
},
|
||||
updateDOMDislikes,
|
||||
);
|
||||
smartimationObserver.container = null;
|
||||
}
|
||||
|
||||
const smartimationContainer = getButtons().querySelector("yt-smartimation");
|
||||
if (
|
||||
smartimationContainer &&
|
||||
smartimationObserver.container != smartimationContainer
|
||||
) {
|
||||
cLog("Initializing smartimation mutation observer");
|
||||
smartimationObserver.disconnect();
|
||||
smartimationObserver.observe(smartimationContainer);
|
||||
smartimationObserver.container = smartimationContainer;
|
||||
}
|
||||
}
|
||||
|
||||
function storageChangeHandler(changes, area) {
|
||||
if (changes.disableVoteSubmission !== undefined) {
|
||||
handleDisableVoteSubmissionChangeEvent(
|
||||
changes.disableVoteSubmission.newValue
|
||||
changes.disableVoteSubmission.newValue,
|
||||
);
|
||||
}
|
||||
if (changes.coloredThumbs !== undefined) {
|
||||
@@ -114,7 +155,7 @@ function storageChangeHandler(changes, area) {
|
||||
}
|
||||
if (changes.numberDisplayReformatLikes !== undefined) {
|
||||
handleNumberDisplayReformatLikesChangeEvent(
|
||||
changes.numberDisplayReformatLikes.newValue
|
||||
changes.numberDisplayReformatLikes.newValue,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -149,5 +190,6 @@ export {
|
||||
likeClicked,
|
||||
dislikeClicked,
|
||||
addLikeDislikeEventListener,
|
||||
createSmartimationObserver,
|
||||
storageChangeHandler,
|
||||
};
|
||||
@@ -9,7 +9,7 @@ function createStarRating(rating, isMobile) {
|
||||
starSlider.setAttribute("readonly", "");
|
||||
starSlider.setAttribute(
|
||||
"style",
|
||||
`--fill:rgb(255, 215, 0);--value:${rating.toString()};};background-color: transparent;`
|
||||
`--fill:rgb(255, 215, 0);--value:${rating.toString()};};background-color: transparent;`,
|
||||
);
|
||||
starSlider.setAttribute("type", "range");
|
||||
|
||||
@@ -19,11 +19,11 @@ function createStarRating(rating, isMobile) {
|
||||
|
||||
if (isMobile) {
|
||||
YTLikeButton = document.querySelector(
|
||||
"#app > div.page-container > ytm-watch > ytm-single-column-watch-next-results-renderer > ytm-slim-video-metadata-section-renderer > ytm-slim-video-action-bar-renderer > div > ytm-slim-metadata-toggle-button-renderer:nth-child(1)"
|
||||
"#app > div.page-container > ytm-watch > ytm-single-column-watch-next-results-renderer > ytm-slim-video-metadata-section-renderer > ytm-slim-video-action-bar-renderer > div > ytm-slim-metadata-toggle-button-renderer:nth-child(1)",
|
||||
);
|
||||
} else {
|
||||
YTLikeButton = document.querySelector(
|
||||
"#top-level-buttons-computed > ytd-toggle-button-renderer:nth-child(1)"
|
||||
"#top-level-buttons-computed > ytd-toggle-button-renderer:nth-child(1)",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+133
-108
@@ -1,10 +1,4 @@
|
||||
import {
|
||||
getLikeButton,
|
||||
getDislikeButton,
|
||||
getButtons,
|
||||
getLikeTextContainer,
|
||||
getDislikeTextContainer,
|
||||
} from "./buttons";
|
||||
import { getLikeButton, getDislikeButton, getButtons, getLikeTextContainer, getDislikeTextContainer } from "./buttons";
|
||||
import { createRateBar } from "./bar";
|
||||
import {
|
||||
getBrowser,
|
||||
@@ -12,9 +6,10 @@ import {
|
||||
cLog,
|
||||
numberFormat,
|
||||
getColorFromTheme,
|
||||
querySelector,
|
||||
localize,
|
||||
createObserver,
|
||||
} from "./utils";
|
||||
import { localize } from "./utils";
|
||||
import { createStarRating } from "./starRating";
|
||||
|
||||
//TODO: Do not duplicate here and in ryd.background.js
|
||||
const apiUrl = "https://returnyoutubedislikeapi.com";
|
||||
@@ -24,6 +19,7 @@ const NEUTRAL_STATE = "NEUTRAL_STATE";
|
||||
|
||||
let extConfig = {
|
||||
disableVoteSubmission: false,
|
||||
disableLogging: false,
|
||||
coloredThumbs: false,
|
||||
coloredBar: false,
|
||||
colorTheme: "classic",
|
||||
@@ -31,6 +27,33 @@ let extConfig = {
|
||||
showTooltipPercentage: false,
|
||||
tooltipPercentageMode: "dash_like",
|
||||
numberDisplayReformatLikes: false,
|
||||
selectors: {
|
||||
dislikeTextContainer: [],
|
||||
likeTextContainer: [],
|
||||
buttons: {
|
||||
shorts: {
|
||||
mobile: [],
|
||||
desktop: [],
|
||||
},
|
||||
regular: {
|
||||
mobile: [],
|
||||
desktopMenu: [],
|
||||
desktopNoMenu: [],
|
||||
},
|
||||
likeButton: {
|
||||
segmented: [],
|
||||
segmentedGetButtons: [],
|
||||
notSegmented: [],
|
||||
},
|
||||
dislikeButton: {
|
||||
segmented: [],
|
||||
segmentedGetButtons: [],
|
||||
notSegmented: [],
|
||||
},
|
||||
},
|
||||
menuContainer: [],
|
||||
roundedDesign: [],
|
||||
},
|
||||
};
|
||||
|
||||
let storedData = {
|
||||
@@ -52,73 +75,67 @@ function isNewDesign() {
|
||||
}
|
||||
|
||||
function isRoundedDesign() {
|
||||
return document.getElementById("segmented-like-button") !== null;
|
||||
return querySelector(extConfig.selectors.roundedDesign) !== null;
|
||||
}
|
||||
|
||||
let mutationObserver = new Object();
|
||||
let shortsObserver = null;
|
||||
|
||||
if (isShorts() && mutationObserver.exists !== true) {
|
||||
cLog("initializing mutation observer");
|
||||
mutationObserver.options = {
|
||||
childList: false,
|
||||
attributes: true,
|
||||
subtree: false,
|
||||
};
|
||||
mutationObserver.exists = true;
|
||||
mutationObserver.observer = new MutationObserver(function (
|
||||
mutationList,
|
||||
observer
|
||||
) {
|
||||
mutationList.forEach((mutation) => {
|
||||
if (
|
||||
mutation.type === "attributes" &&
|
||||
mutation.target.nodeName === "TP-YT-PAPER-BUTTON" &&
|
||||
mutation.target.id === "button"
|
||||
) {
|
||||
// cLog('Short thumb button status changed');
|
||||
if (mutation.target.getAttribute("aria-pressed") === "true") {
|
||||
mutation.target.style.color =
|
||||
mutation.target.parentElement.parentElement.id === "like-button"
|
||||
? getColorFromTheme(true)
|
||||
: getColorFromTheme(false);
|
||||
} else {
|
||||
mutation.target.style.color = "unset";
|
||||
if (isShorts() && !shortsObserver) {
|
||||
cLog("Initializing shorts mutation observer");
|
||||
shortsObserver = createObserver(
|
||||
{
|
||||
attributes: true,
|
||||
},
|
||||
(mutationList) => {
|
||||
mutationList.forEach((mutation) => {
|
||||
if (
|
||||
mutation.type === "attributes" &&
|
||||
mutation.target.nodeName === "TP-YT-PAPER-BUTTON" &&
|
||||
mutation.target.id === "button"
|
||||
) {
|
||||
// cLog('Short thumb button status changed');
|
||||
if (mutation.target.getAttribute("aria-pressed") === "true") {
|
||||
mutation.target.style.color =
|
||||
mutation.target.parentElement.parentElement.id === "like-button"
|
||||
? getColorFromTheme(true)
|
||||
: getColorFromTheme(false);
|
||||
} else {
|
||||
mutation.target.style.color = "unset";
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
cLog(
|
||||
"unexpected mutation observer event: " + mutation.target + mutation.type
|
||||
);
|
||||
});
|
||||
});
|
||||
cLog("Unexpected mutation observer event: " + mutation.target + mutation.type);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function isLikesDisabled() {
|
||||
// return true if the like button's text doesn't contain any number
|
||||
if (isMobile()) {
|
||||
return /^\D*$/.test(
|
||||
getButtons().children[0].querySelector(".button-renderer-text").innerText
|
||||
);
|
||||
return /^\D*$/.test(getButtons().children[0].querySelector(".button-renderer-text").innerText);
|
||||
}
|
||||
return /^\D*$/.test(getButtons().children[0].innerText);
|
||||
return /^\D*$/.test(getLikeTextContainer().innerText);
|
||||
}
|
||||
|
||||
function isVideoLiked() {
|
||||
if (isMobile()) {
|
||||
return (
|
||||
getLikeButton().querySelector("button").getAttribute("aria-label") === "true"
|
||||
);
|
||||
return getLikeButton().querySelector("button").getAttribute("aria-label") === "true";
|
||||
}
|
||||
return getLikeButton().classList.contains("style-default-active") || getLikeButton().querySelector('button')?.getAttribute('aria-pressed') === 'true';
|
||||
return (
|
||||
getLikeButton().classList.contains("style-default-active") ||
|
||||
getLikeButton().querySelector("button")?.getAttribute("aria-pressed") === "true"
|
||||
);
|
||||
}
|
||||
|
||||
function isVideoDisliked() {
|
||||
if (isMobile()) {
|
||||
return (
|
||||
getDislikeButton().querySelector("button").getAttribute("aria-label") === "true"
|
||||
);
|
||||
return getDislikeButton().querySelector("button").getAttribute("aria-label") === "true";
|
||||
}
|
||||
return getDislikeButton().classList.contains("style-default-active") || getDislikeButton().querySelector('button')?.getAttribute('aria-pressed') === 'true';
|
||||
return (
|
||||
getDislikeButton().classList.contains("style-default-active") ||
|
||||
getDislikeButton().querySelector("button")?.getAttribute("aria-pressed") === "true"
|
||||
);
|
||||
}
|
||||
|
||||
function getState(storedData) {
|
||||
@@ -133,32 +150,34 @@ function getState(storedData) {
|
||||
|
||||
//--- Sets The Likes And Dislikes Values ---//
|
||||
function setLikes(likesCount) {
|
||||
cLog(`SET likes ${likesCount}`)
|
||||
cLog(`SET likes ${likesCount}`);
|
||||
getLikeTextContainer().innerText = likesCount;
|
||||
}
|
||||
|
||||
function setDislikes(dislikesCount) {
|
||||
cLog(`SET dislikes ${dislikesCount}`)
|
||||
getDislikeTextContainer()?.removeAttribute("is-empty");
|
||||
getDislikeTextContainer()?.removeAttribute('is-empty');
|
||||
cLog(`SET dislikes ${dislikesCount}`);
|
||||
|
||||
const _container = getDislikeTextContainer();
|
||||
_container?.removeAttribute("is-empty");
|
||||
|
||||
let _dislikeText
|
||||
if (!isLikesDisabled()) {
|
||||
if (isMobile()) {
|
||||
getButtons().children[1].querySelector(
|
||||
".button-renderer-text"
|
||||
).innerText = dislikesCount;
|
||||
getButtons().children[1].querySelector(".button-renderer-text").innerText = dislikesCount;
|
||||
return;
|
||||
}
|
||||
getDislikeTextContainer().innerText = dislikesCount;
|
||||
|
||||
_dislikeText = dislikesCount;
|
||||
} else {
|
||||
cLog("likes count disabled by creator");
|
||||
if (isMobile()) {
|
||||
getButtons().children[1].querySelector(
|
||||
".button-renderer-text"
|
||||
).innerText = localize("TextLikesDisabled");
|
||||
getButtons().children[1].querySelector(".button-renderer-text").innerText = localize("TextLikesDisabled");
|
||||
return;
|
||||
}
|
||||
getDislikeTextContainer().innerText = localize("TextLikesDisabled");
|
||||
_dislikeText = localize("TextLikesDisabled");
|
||||
}
|
||||
|
||||
if (_dislikeText != null && _container?.innerText !== _dislikeText) {
|
||||
_container.innerText = _dislikeText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,12 +189,10 @@ function getLikeCountFromButton() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let likeButton = getLikeButton()
|
||||
.querySelector("yt-formatted-string#text") ??
|
||||
getLikeButton().querySelector("button");
|
||||
let likeButton =
|
||||
getLikeButton().querySelector("yt-formatted-string#text") ?? getLikeButton().querySelector("button");
|
||||
|
||||
let likesStr = likeButton.getAttribute("aria-label")
|
||||
.replace(/\D/g, "");
|
||||
let likesStr = likeButton.getAttribute("aria-label").replace(/\D/g, "");
|
||||
return likesStr.length > 0 ? parseInt(likesStr) : false;
|
||||
} catch {
|
||||
return false;
|
||||
@@ -197,26 +214,16 @@ function processResponse(response, storedData) {
|
||||
if (extConfig.coloredThumbs === true) {
|
||||
if (isShorts()) {
|
||||
// for shorts, leave deactivated buttons in default color
|
||||
let shortLikeButton = getLikeButton().querySelector(
|
||||
"tp-yt-paper-button#button"
|
||||
);
|
||||
let shortDislikeButton = getDislikeButton().querySelector(
|
||||
"tp-yt-paper-button#button"
|
||||
);
|
||||
let shortLikeButton = getLikeButton().querySelector("tp-yt-paper-button#button");
|
||||
let shortDislikeButton = getDislikeButton().querySelector("tp-yt-paper-button#button");
|
||||
if (shortLikeButton.getAttribute("aria-pressed") === "true") {
|
||||
shortLikeButton.style.color = getColorFromTheme(true);
|
||||
}
|
||||
if (shortDislikeButton.getAttribute("aria-pressed") === "true") {
|
||||
shortDislikeButton.style.color = getColorFromTheme(false);
|
||||
}
|
||||
mutationObserver.observer.observe(
|
||||
shortLikeButton,
|
||||
mutationObserver.options
|
||||
);
|
||||
mutationObserver.observer.observe(
|
||||
shortDislikeButton,
|
||||
mutationObserver.options
|
||||
);
|
||||
shortsObserver.observe(shortLikeButton);
|
||||
shortsObserver.observe(shortDislikeButton);
|
||||
} else {
|
||||
getLikeButton().style.color = getColorFromTheme(true);
|
||||
getDislikeButton().style.color = getColorFromTheme(false);
|
||||
@@ -228,31 +235,23 @@ function processResponse(response, storedData) {
|
||||
|
||||
// Tells the user if the API is down
|
||||
function displayError(error) {
|
||||
getDislikeTextContainer().innerText = localize(
|
||||
"textTempUnavailable"
|
||||
);
|
||||
getDislikeTextContainer().innerText = localize("textTempUnavailable");
|
||||
}
|
||||
|
||||
async function setState(storedData) {
|
||||
storedData.previousState = isVideoDisliked()
|
||||
? DISLIKED_STATE
|
||||
: isVideoLiked()
|
||||
? LIKED_STATE
|
||||
: NEUTRAL_STATE;
|
||||
storedData.previousState = isVideoDisliked() ? DISLIKED_STATE : isVideoLiked() ? LIKED_STATE : NEUTRAL_STATE;
|
||||
let statsSet = false;
|
||||
cLog("Video is loaded. Adding buttons...");
|
||||
|
||||
let videoId = getVideoId(window.location.href);
|
||||
let likeCount = getLikeCountFromButton() || null;
|
||||
|
||||
let response = await fetch(
|
||||
`${apiUrl}/votes?videoId=${videoId}&likeCount=${likeCount || ""}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
}
|
||||
)
|
||||
let response = await fetch(`${apiUrl}/votes?videoId=${videoId}&likeCount=${likeCount || ""}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) displayError(response.error);
|
||||
return response;
|
||||
@@ -266,12 +265,13 @@ async function setState(storedData) {
|
||||
}
|
||||
}
|
||||
|
||||
function setInitialState() {
|
||||
setState(storedData);
|
||||
async function setInitialState() {
|
||||
await setState(storedData);
|
||||
}
|
||||
|
||||
function initExtConfig() {
|
||||
async function initExtConfig() {
|
||||
initializeDisableVoteSubmission();
|
||||
initializeDisableLogging();
|
||||
initializeColoredThumbs();
|
||||
initializeColoredBar();
|
||||
initializeColorTheme();
|
||||
@@ -279,6 +279,21 @@ function initExtConfig() {
|
||||
initializeTooltipPercentage();
|
||||
initializeTooltipPercentageMode();
|
||||
initializeNumberDisplayReformatLikes();
|
||||
await initializeSelectors();
|
||||
}
|
||||
|
||||
async function initializeSelectors() {
|
||||
console.log("initializing selectors");
|
||||
let result = await fetch(`${apiUrl}/configs/selectors`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.catch((error) => {});
|
||||
extConfig.selectors = result ?? extConfig.selectors;
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
function initializeDisableVoteSubmission() {
|
||||
@@ -291,6 +306,16 @@ function initializeDisableVoteSubmission() {
|
||||
});
|
||||
}
|
||||
|
||||
function initializeDisableLogging() {
|
||||
getBrowser().storage.sync.get(["disableLogging"], (res) => {
|
||||
if (res.disableLogging === undefined) {
|
||||
getBrowser().storage.sync.set({ disableLogging: true });
|
||||
} else {
|
||||
extConfig.disableLogging = res.disableLogging;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initializeColoredThumbs() {
|
||||
getBrowser().storage.sync.get(["coloredThumbs"], (res) => {
|
||||
if (res.coloredThumbs === undefined) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { extConfig } from "./state";
|
||||
|
||||
function numberFormat(numberState) {
|
||||
return getNumberFormatter(extConfig.numberDisplayFormat).format(
|
||||
numberState
|
||||
);
|
||||
return getNumberFormatter(extConfig.numberDisplayFormat).format(numberState);
|
||||
}
|
||||
|
||||
function getNumberFormatter(optionSelect) {
|
||||
@@ -17,12 +15,10 @@ function getNumberFormatter(optionSelect) {
|
||||
userLocales = new URL(
|
||||
Array.from(document.querySelectorAll("head > link[rel='search']"))
|
||||
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
|
||||
?.getAttribute("href")
|
||||
?.getAttribute("href"),
|
||||
)?.searchParams?.get("locale");
|
||||
} catch {
|
||||
cLog(
|
||||
"Cannot find browser locale. Use en as default for number formatting."
|
||||
);
|
||||
cLog("Cannot find browser locale. Use en as default for number formatting.");
|
||||
userLocales = "en";
|
||||
}
|
||||
}
|
||||
@@ -58,10 +54,7 @@ function localize(localeString) {
|
||||
function getBrowser() {
|
||||
if (typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined") {
|
||||
return chrome;
|
||||
} else if (
|
||||
typeof browser !== "undefined" &&
|
||||
typeof browser.runtime !== "undefined"
|
||||
) {
|
||||
} else if (typeof browser !== "undefined" && typeof browser.runtime !== "undefined") {
|
||||
return browser;
|
||||
} else {
|
||||
console.log("browser is not supported");
|
||||
@@ -73,7 +66,8 @@ function getVideoId(url) {
|
||||
const urlObject = new URL(url);
|
||||
const pathname = urlObject.pathname;
|
||||
if (pathname.startsWith("/clip")) {
|
||||
return document.querySelector("meta[itemprop='videoId']").content;
|
||||
return (document.querySelector("meta[itemprop='videoId']") || document.querySelector("meta[itemprop='identifier']"))
|
||||
.content;
|
||||
} else {
|
||||
if (pathname.startsWith("/shorts")) {
|
||||
return pathname.slice(8);
|
||||
@@ -100,6 +94,9 @@ function isInViewport(element) {
|
||||
function isVideoLoaded() {
|
||||
const videoId = getVideoId(window.location.href);
|
||||
return (
|
||||
// desktop: spring 2024 UI
|
||||
document.querySelector(`ytd-watch-grid[video-id='${videoId}']`) !== null ||
|
||||
// desktop: older UI
|
||||
document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null ||
|
||||
// mobile: no video-id attribute
|
||||
document.querySelector('#player[loading="false"]:not([hidden])') !== null
|
||||
@@ -107,11 +104,13 @@ function isVideoLoaded() {
|
||||
}
|
||||
|
||||
function cLog(message, writer) {
|
||||
message = `[return youtube dislike]: ${message}`;
|
||||
if (writer) {
|
||||
writer(message);
|
||||
} else {
|
||||
console.log(message);
|
||||
if (!extConfig.disableLogging) {
|
||||
message = `[return youtube dislike]: ${message}`;
|
||||
if (writer) {
|
||||
writer(message);
|
||||
} else {
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,8 +142,43 @@ function getColorFromTheme(voteIsLike) {
|
||||
return colorString;
|
||||
}
|
||||
|
||||
function querySelector(selectors, element) {
|
||||
let result;
|
||||
for (const selector of selectors) {
|
||||
result = (element ?? document).querySelector(selector);
|
||||
if (result !== null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function querySelectorAll(selectors) {
|
||||
let result;
|
||||
for (const selector of selectors) {
|
||||
result = document.querySelectorAll(selector);
|
||||
if (result.length !== 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function createObserver(options, callback) {
|
||||
const observerWrapper = new Object();
|
||||
observerWrapper.options = options;
|
||||
observerWrapper.observer = new MutationObserver(callback);
|
||||
observerWrapper.observe = function (element) {
|
||||
this.observer.observe(element, this.options);
|
||||
};
|
||||
observerWrapper.disconnect = function () {
|
||||
this.observer.disconnect();
|
||||
};
|
||||
return observerWrapper;
|
||||
}
|
||||
|
||||
export {
|
||||
numberFormat,
|
||||
getNumberFormatter,
|
||||
getBrowser,
|
||||
getVideoId,
|
||||
isInViewport,
|
||||
@@ -152,4 +186,7 @@ export {
|
||||
cLog,
|
||||
getColorFromTheme,
|
||||
localize,
|
||||
querySelector,
|
||||
querySelectorAll,
|
||||
createObserver,
|
||||
};
|
||||
@@ -0,0 +1,325 @@
|
||||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import {
|
||||
__Rewire__ as rewiredUtils,
|
||||
numberFormat,
|
||||
getNumberFormatter,
|
||||
localize,
|
||||
getBrowser,
|
||||
getVideoId,
|
||||
isInViewport,
|
||||
isVideoLoaded,
|
||||
cLog,
|
||||
getColorFromTheme,
|
||||
} from "./utils";
|
||||
import { extConfig } from "./state";
|
||||
|
||||
jest.mock("./state");
|
||||
|
||||
describe("numberFormat", () => {
|
||||
it("should format high numbers correctly", () => {
|
||||
rewiredUtils(
|
||||
"getNumberFormatter",
|
||||
jest.fn().mockReturnValue(
|
||||
Intl.NumberFormat("en", {
|
||||
notation: "compact",
|
||||
compactDisplay: "short",
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
expect(numberFormat(91492)).toBe("91K");
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should not format input when < 1000", () => {
|
||||
rewiredUtils(
|
||||
"getNumberFormatter",
|
||||
jest.fn().mockReturnValue(
|
||||
Intl.NumberFormat("en", {
|
||||
notation: "compact",
|
||||
compactDisplay: "short",
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
expect(numberFormat(100)).toBe("100");
|
||||
});
|
||||
|
||||
it("should not round down when rounding is diabled in config", () => {
|
||||
rewiredUtils(
|
||||
"getNumberFormatter",
|
||||
jest.fn().mockReturnValue(
|
||||
Intl.NumberFormat("de", {
|
||||
notation: "compact",
|
||||
compactDisplay: "short",
|
||||
}),
|
||||
),
|
||||
);
|
||||
extConfig.numberDisplayRoundDown = false;
|
||||
|
||||
expect(numberFormat(912391)).toBe("912.391");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getNumberFormatter", () => {
|
||||
it("should return a correct formatter with compactLong option", () => {
|
||||
expect(getNumberFormatter("compactLong")).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should return a correct formatter whith standard option", () => {
|
||||
expect(getNumberFormatter("standard")).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should return a correct formatter when using chrome", () => {
|
||||
Object.defineProperty(document.documentElement, "lang", {
|
||||
value: "en",
|
||||
configurable: true,
|
||||
});
|
||||
expect(getNumberFormatter()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should return a correct formatter when using firefox", () => {
|
||||
Object.defineProperty(document.documentElement, "lang", {
|
||||
value: null,
|
||||
configurable: true,
|
||||
});
|
||||
expect(getNumberFormatter()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should return a correct formatter when using the URL locale (possibly buggy)", () => {
|
||||
// Disclaimer: The case we are testing here is actually not correct and
|
||||
// am almost sure I found a bug in the actual implementation of
|
||||
// getNumberFormatter(). As I am currently writing acceptance tests only
|
||||
// e.g. tests that are exclusively testing the current behaviour as is, as
|
||||
// a first step of adding tests to the codebase, I will add it like this
|
||||
// for now and document how we should actually be testing down below.
|
||||
// The reason why this bug is not causing faulty behaviour is, that we
|
||||
// have a fallback for it, that is always triggered.
|
||||
|
||||
// This is how we make the test go green:
|
||||
Object.defineProperty(document.documentElement, "lang", {
|
||||
value: null,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(navigator, "language", {
|
||||
value: null,
|
||||
configurable: true,
|
||||
});
|
||||
const mockedNode = document.createElement("link");
|
||||
|
||||
mockedNode.setAttribute("href", "https://www.youtube.com/opensearch?locale=en");
|
||||
|
||||
document.querySelectorAll = jest.fn().mockReturnValue([mockedNode]);
|
||||
expect(getNumberFormatter()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it.skip("should return a correct formatter when using the URL locale", () => {
|
||||
// But we actually want to test like so, which is the correct value of the locale attribute:
|
||||
Object.defineProperty(document.documentElement, "lang", {
|
||||
value: null,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(navigator, "language", {
|
||||
value: null,
|
||||
configurable: true,
|
||||
});
|
||||
const mockedNode = document.createElement("link");
|
||||
mockedNode.setAttribute("href", "https://www.youtube.com/opensearch?locale=en_US");
|
||||
|
||||
document.querySelectorAll = jest.fn().mockReturnValue([mockedNode]);
|
||||
expect(getNumberFormatter()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should return a correct formatter when falling back to default locale", () => {
|
||||
Object.defineProperty(document.documentElement, "lang", {
|
||||
value: null,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(navigator, "language", {
|
||||
value: null,
|
||||
configurable: true,
|
||||
});
|
||||
expect(getNumberFormatter()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe("localize", () => {
|
||||
it("should return a translated string", () => {
|
||||
global.chrome = {
|
||||
i18n: {
|
||||
getMessage: () => "Return YouTube Dislike",
|
||||
},
|
||||
};
|
||||
expect(localize("extensionName")).toBe("Return YouTube Dislike");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getBrowser", () => {
|
||||
it("should return a chrome browser instance", () => {
|
||||
global.chrome = {
|
||||
runtime: jest.fn(),
|
||||
};
|
||||
expect(getBrowser()).toBeDefined();
|
||||
});
|
||||
|
||||
it("should return a mozilla browser instance", () => {
|
||||
global.chrome.runtime = undefined;
|
||||
global.browser = {
|
||||
runtime: jest.fn(),
|
||||
};
|
||||
expect(getBrowser()).toBeDefined();
|
||||
});
|
||||
|
||||
it("should fail on unsupported browser", () => {
|
||||
global.chrome = undefined;
|
||||
global.browser = undefined;
|
||||
|
||||
const log = console.log;
|
||||
console.log = jest.fn();
|
||||
|
||||
expect(getBrowser()).toBe(false);
|
||||
expect(console.log).toBeCalledWith("browser is not supported");
|
||||
|
||||
console.log = log;
|
||||
});
|
||||
});
|
||||
describe("getVideoId", () => {
|
||||
it("should return the video Id on valid url input", () => {
|
||||
const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
|
||||
expect(getVideoId(url)).toBe("dQw4w9WgXcQ");
|
||||
});
|
||||
|
||||
it("should return the video Id on valid shorts url input", () => {
|
||||
const url = "https://www.youtube.com/shorts/niMcQ9Vmmj8";
|
||||
expect(getVideoId(url)).toBe("niMcQ9Vmmj8");
|
||||
});
|
||||
|
||||
it("should return the video Id on clip url input", () => {
|
||||
document.querySelector = jest.fn().mockReturnValue({
|
||||
content: "niMcQ9Vmmj8",
|
||||
});
|
||||
const url = "https://www.youtube.com/clip";
|
||||
expect(getVideoId(url)).toBe("niMcQ9Vmmj8");
|
||||
});
|
||||
|
||||
it("should return null on invalid url input", () => {
|
||||
const url = "https://www.youtube.com/wrong-url";
|
||||
expect(getVideoId(url)).toBe(null);
|
||||
});
|
||||
});
|
||||
describe("isInViewport", () => {
|
||||
it("should return true if element is in viewport", () => {
|
||||
const rect = {
|
||||
getBoundingClientRect: jest.fn().mockReturnValue({
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
}),
|
||||
};
|
||||
expect(isInViewport(rect)).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false if element is out of viewport", () => {
|
||||
const rect = {
|
||||
getBoundingClientRect: jest.fn().mockReturnValue({
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: 769,
|
||||
right: 0,
|
||||
}),
|
||||
};
|
||||
expect(isInViewport(rect)).toBe(false);
|
||||
});
|
||||
});
|
||||
describe("isVideoLoaded", () => {
|
||||
describe("on desktop", () => {
|
||||
it("should return true on loaded video", () => {
|
||||
rewiredUtils("getVideoId", jest.fn().mockReturnValue("fakeId"));
|
||||
document.querySelector = jest.fn().mockReturnValue("notNull");
|
||||
expect(isVideoLoaded()).toBe(true);
|
||||
expect(document.querySelector).toBeCalledWith("ytd-watch-grid[video-id='fakeId']");
|
||||
});
|
||||
|
||||
it("should return false on not loaded video", () => {
|
||||
rewiredUtils("getVideoId", jest.fn().mockReturnValue("fakeId"));
|
||||
document.querySelector = jest.fn().mockReturnValue(null);
|
||||
expect(isVideoLoaded()).toBe(false);
|
||||
expect(document.querySelector).toBeCalledWith("ytd-watch-flexy[video-id='fakeId']");
|
||||
});
|
||||
});
|
||||
|
||||
describe("on mobile", () => {
|
||||
it("should return true on loaded video", () => {
|
||||
rewiredUtils("getVideoId", jest.fn().mockReturnValue("fakeId"));
|
||||
document.querySelector = jest.fn().mockReturnValueOnce(null).mockReturnValue("notNull");
|
||||
expect(isVideoLoaded()).toBe(true);
|
||||
expect(document.querySelector).toHaveBeenLastCalledWith("ytd-watch-flexy[video-id='fakeId']");
|
||||
});
|
||||
|
||||
it("should return false on not loaded video", () => {
|
||||
rewiredUtils("getVideoId", jest.fn().mockReturnValue("fakeId"));
|
||||
document.querySelector = jest.fn().mockReturnValueOnce(null).mockReturnValue(null);
|
||||
expect(isVideoLoaded()).toBe(false);
|
||||
expect(document.querySelector).toHaveBeenLastCalledWith('#player[loading="false"]:not([hidden])');
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("cLog", () => {
|
||||
it("should log a message with the correct prefix", () => {
|
||||
const log = console.log;
|
||||
console.log = jest.fn();
|
||||
cLog("Test message");
|
||||
|
||||
expect(console.log).toBeCalledWith("[return youtube dislike]: Test message");
|
||||
|
||||
console.log = log;
|
||||
});
|
||||
|
||||
it("should log a message with the correct prefix when given a writer", () => {
|
||||
const fakeWriter = jest.fn();
|
||||
|
||||
cLog("Test message", fakeWriter);
|
||||
expect(fakeWriter).toBeCalledWith("[return youtube dislike]: Test message");
|
||||
});
|
||||
});
|
||||
describe("getColorFromTheme", () => {
|
||||
describe("accessible", () => {
|
||||
it("should return the correct color for like", () => {
|
||||
extConfig.colorTheme = "accessible";
|
||||
expect(getColorFromTheme(true)).toBe("dodgerblue");
|
||||
});
|
||||
|
||||
it("should return the correct color for not liked", () => {
|
||||
extConfig.colorTheme = "accessible";
|
||||
expect(getColorFromTheme(false)).toBe("gold");
|
||||
});
|
||||
});
|
||||
|
||||
describe("neon", () => {
|
||||
it("should return the correct color for like", () => {
|
||||
extConfig.colorTheme = "neon";
|
||||
expect(getColorFromTheme(true)).toBe("aqua");
|
||||
});
|
||||
|
||||
it("should return the correct color for not liked", () => {
|
||||
extConfig.colorTheme = "neon";
|
||||
expect(getColorFromTheme(false)).toBe("magenta");
|
||||
});
|
||||
});
|
||||
|
||||
describe("classic", () => {
|
||||
it("should return the correct color for like", () => {
|
||||
extConfig.colorTheme = "classic";
|
||||
expect(getColorFromTheme(true)).toBe("lime");
|
||||
});
|
||||
|
||||
it("should return the correct color for not liked", () => {
|
||||
extConfig.colorTheme = "classic";
|
||||
expect(getColorFromTheme(false)).toBe("red");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user