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

github.com/Anarios/return-youtube-dislike.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Extensions')
-rw-r--r--Extensions/combined/manifest-chrome.json4
-rw-r--r--Extensions/combined/manifest-firefox.json16
-rw-r--r--Extensions/combined/src/bar.js6
-rw-r--r--Extensions/combined/src/buttons.js23
-rw-r--r--Extensions/combined/src/events.js11
-rw-r--r--Extensions/combined/src/state.js22
6 files changed, 50 insertions, 32 deletions
diff --git a/Extensions/combined/manifest-chrome.json b/Extensions/combined/manifest-chrome.json
index da2e082..95fe7e9 100644
--- a/Extensions/combined/manifest-chrome.json
+++ b/Extensions/combined/manifest-chrome.json
@@ -1,8 +1,8 @@
{
- "name": "__MSG_extensionNameBeta__",
+ "name": "__MSG_extensionName__",
"description": "__MSG_extensionDesc__",
"default_locale": "en",
- "version": "3.0.0.2",
+ "version": "3.0.0.4",
"manifest_version": 3,
"background": {
"service_worker": "ryd.background.js"
diff --git a/Extensions/combined/manifest-firefox.json b/Extensions/combined/manifest-firefox.json
index 4f7ba04..efb42a4 100644
--- a/Extensions/combined/manifest-firefox.json
+++ b/Extensions/combined/manifest-firefox.json
@@ -2,7 +2,7 @@
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDesc__",
"default_locale": "en",
- "version": "3.0.0.3",
+ "version": "3.0.0.5",
"manifest_version": 2,
"background": {
"scripts": ["ryd.background.js"]
@@ -28,12 +28,12 @@
"css": ["content-style.css"],
"js": ["ryd.content-script.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"
- }
- }
+// "browser_specific_settings": {
+// "gecko": {
+// "id": "addon@example.com",
+// "strict_min_version": "42.0"
+// }
+// }
}
diff --git a/Extensions/combined/src/bar.js b/Extensions/combined/src/bar.js
index 55f21ed..930f0f5 100644
--- a/Extensions/combined/src/bar.js
+++ b/Extensions/combined/src/bar.js
@@ -1,4 +1,4 @@
-import { getButtons } from "./buttons";
+import { getButtons, getDislikeButton, getLikeButton } from './buttons';
import {
extConfig,
isMobile,
@@ -13,8 +13,8 @@ function createRateBar(likes, dislikes) {
let rateBar = document.getElementById("ryd-bar-container");
const widthPx =
- getButtons().children[0].clientWidth +
- getButtons().children[1].clientWidth +
+ getLikeButton().clientWidth +
+ getDislikeButton().clientWidth +
8;
const widthPercent =
diff --git a/Extensions/combined/src/buttons.js b/Extensions/combined/src/buttons.js
index 3b8cab4..6b344d9 100644
--- a/Extensions/combined/src/buttons.js
+++ b/Extensions/combined/src/buttons.js
@@ -33,7 +33,10 @@ function getButtons() {
}
function getLikeButton() {
- return getButtons().children[0];
+ return getButtons().children[0].tagName ===
+ "YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER"
+ ? getButtons().children[0].children[0]
+ : getButtons().children[0];
}
function getLikeTextContainer() {
@@ -44,14 +47,24 @@ function getLikeTextContainer() {
}
function getDislikeButton() {
- return getButtons().children[1];
+ return getButtons().children[0].tagName ===
+ "YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER"
+ ? getButtons().children[0].children[1]
+ : getButtons().children[1];
}
function getDislikeTextContainer() {
- return (
+ let result =
getDislikeButton().querySelector("#text") ??
- getDislikeButton().getElementsByTagName("yt-formatted-string")[0]
- );
+ getDislikeButton().getElementsByTagName("yt-formatted-string")[0];
+ if (result == null) {
+ let textSpan = document.createElement("span");
+ textSpan.id = "text";
+ getDislikeButton().querySelector("button").appendChild(textSpan);
+ getDislikeButton().querySelector("button").style.width = "auto";
+ result = getDislikeButton().querySelector("#text");
+ }
+ return result;
}
function checkForSignInButton() {
diff --git a/Extensions/combined/src/events.js b/Extensions/combined/src/events.js
index 47d0bce..a7638dc 100644
--- a/Extensions/combined/src/events.js
+++ b/Extensions/combined/src/events.js
@@ -1,5 +1,5 @@
import { getBrowser, getVideoId, numberFormat, cLog } from "./utils";
-import { checkForSignInButton, getButtons } from "./buttons";
+import { checkForSignInButton, getButtons, getDislikeButton, getLikeButton } from './buttons';
import {
NEUTRAL_STATE,
LIKED_STATE,
@@ -83,12 +83,11 @@ function dislikeClicked() {
}
function addLikeDislikeEventListener() {
- const buttons = getButtons();
if (!window.returnDislikeButtonlistenersSet) {
- buttons.children[0].addEventListener("click", likeClicked);
- buttons.children[1].addEventListener("click", dislikeClicked);
- buttons.children[0].addEventListener("touchstart", likeClicked);
- buttons.children[1].addEventListener("touchstart", dislikeClicked);
+ getLikeButton().addEventListener("click", likeClicked);
+ getDislikeButton().addEventListener("click", dislikeClicked);
+ getLikeButton().addEventListener("touchstart", likeClicked);
+ getLikeButton().addEventListener("touchstart", dislikeClicked);
window.returnDislikeButtonlistenersSet = true;
}
}
diff --git a/Extensions/combined/src/state.js b/Extensions/combined/src/state.js
index 5610d2f..8ee119f 100644
--- a/Extensions/combined/src/state.js
+++ b/Extensions/combined/src/state.js
@@ -97,7 +97,7 @@ function isLikesDisabled() {
);
}
return /^\D*$/.test(
- getButtons().children[0].querySelector("#text").innerText
+ getButtons().children[0].innerText
);
}
@@ -158,16 +158,22 @@ function setDislikes(dislikesCount) {
}
function getLikeCountFromButton() {
- if (isShorts()) {
- //Youtube Shorts don't work with this query. It's not nessecary; we can skip it and still see the results.
- //It should be possible to fix this function, but it's not critical to showing the dislike count.
- return false;
- }
- let likesStr = getLikeButton()
+ try {
+ if (isShorts()) {
+ //Youtube Shorts don't work with this query. It's not nessecary; we can skip it and still see the results.
+ //It should be possible to fix this function, but it's not critical to showing the dislike count.
+ return false;
+ }
+ let likesStr = getLikeButton()
.querySelector("yt-formatted-string#text")
.getAttribute("aria-label")
.replace(/\D/g, "");
- return likesStr.length > 0 ? parseInt(likesStr) : false;
+ return likesStr.length > 0 ? parseInt(likesStr) : false;
+ }
+ catch {
+ return false;
+ }
+
}
function processResponse(response, storedData) {