mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-02 10:52:20 +01:00
New layout fix
This commit is contained in:
1 parent
63673f3089
commit
2d9809ad31
5 files changed
+39
-21
No files matched your search
@@ -2,7 +2,7 @@
|
|||||||
"name": "__MSG_extensionName__",
|
"name": "__MSG_extensionName__",
|
||||||
"description": "__MSG_extensionDesc__",
|
"description": "__MSG_extensionDesc__",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"version": "3.0.0.4",
|
"version": "3.0.0.5",
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"background": {
|
"background": {
|
||||||
"service_worker": "ryd.background.js"
|
"service_worker": "ryd.background.js"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "__MSG_extensionName__",
|
"name": "__MSG_extensionName__",
|
||||||
"description": "__MSG_extensionDesc__",
|
"description": "__MSG_extensionDesc__",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"version": "3.0.0.4",
|
"version": "3.0.0.5",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["ryd.background.js"]
|
"scripts": ["ryd.background.js"]
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ function getButtons() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLikeButton() {
|
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() {
|
function getLikeTextContainer() {
|
||||||
@@ -44,14 +47,24 @@ function getLikeTextContainer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDislikeButton() {
|
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() {
|
function getDislikeTextContainer() {
|
||||||
return (
|
let result =
|
||||||
getDislikeButton().querySelector("#text") ??
|
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() {
|
function checkForSignInButton() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { getBrowser, getVideoId, numberFormat, cLog } from "./utils";
|
import { getBrowser, getVideoId, numberFormat, cLog } from "./utils";
|
||||||
import { checkForSignInButton, getButtons } from "./buttons";
|
import { checkForSignInButton, getButtons, getDislikeButton, getLikeButton } from './buttons';
|
||||||
import {
|
import {
|
||||||
NEUTRAL_STATE,
|
NEUTRAL_STATE,
|
||||||
LIKED_STATE,
|
LIKED_STATE,
|
||||||
@@ -83,12 +83,11 @@ function dislikeClicked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addLikeDislikeEventListener() {
|
function addLikeDislikeEventListener() {
|
||||||
const buttons = getButtons();
|
|
||||||
if (!window.returnDislikeButtonlistenersSet) {
|
if (!window.returnDislikeButtonlistenersSet) {
|
||||||
buttons.children[0].addEventListener("click", likeClicked);
|
getLikeButton().addEventListener("click", likeClicked);
|
||||||
buttons.children[1].addEventListener("click", dislikeClicked);
|
getDislikeButton().addEventListener("click", dislikeClicked);
|
||||||
buttons.children[0].addEventListener("touchstart", likeClicked);
|
getLikeButton().addEventListener("touchstart", likeClicked);
|
||||||
buttons.children[1].addEventListener("touchstart", dislikeClicked);
|
getLikeButton().addEventListener("touchstart", dislikeClicked);
|
||||||
window.returnDislikeButtonlistenersSet = true;
|
window.returnDislikeButtonlistenersSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ function isLikesDisabled() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return /^\D*$/.test(
|
return /^\D*$/.test(
|
||||||
getButtons().children[0].querySelector("#text").innerText
|
getButtons().children[0].innerText
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,16 +158,22 @@ function setDislikes(dislikesCount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLikeCountFromButton() {
|
function getLikeCountFromButton() {
|
||||||
if (isShorts()) {
|
try {
|
||||||
//Youtube Shorts don't work with this query. It's not nessecary; we can skip it and still see the results.
|
if (isShorts()) {
|
||||||
//It should be possible to fix this function, but it's not critical to showing the dislike count.
|
//Youtube Shorts don't work with this query. It's not nessecary; we can skip it and still see the results.
|
||||||
return false;
|
//It should be possible to fix this function, but it's not critical to showing the dislike count.
|
||||||
}
|
return false;
|
||||||
let likesStr = getLikeButton()
|
}
|
||||||
|
let likesStr = getLikeButton()
|
||||||
.querySelector("yt-formatted-string#text")
|
.querySelector("yt-formatted-string#text")
|
||||||
.getAttribute("aria-label")
|
.getAttribute("aria-label")
|
||||||
.replace(/\D/g, "");
|
.replace(/\D/g, "");
|
||||||
return likesStr.length > 0 ? parseInt(likesStr) : false;
|
return likesStr.length > 0 ? parseInt(likesStr) : false;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function processResponse(response, storedData) {
|
function processResponse(response, storedData) {
|
||||||
|
|||||||
Reference in new issue
Block a user