New YouTube UI fix for userscript and extension

This commit is contained in:
Anarios committed 2023-05-10 10:47:27 +02:00
1 parent 2cb137ddf6
commit 5c73825aad
20 files changed
+37 -50

No files matched your search

+2 -2
View File
@@ -35,7 +35,7 @@ function getButtons() {
function getLikeButton() {
return getButtons().children[0].tagName ===
"YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER"
? getButtons().children[0].children[0]
? document.querySelector("#segmented-like-button") !== null ? document.querySelector("#segmented-like-button") : getButtons().children[0].children[0]
: getButtons().children[0];
}
@@ -50,7 +50,7 @@ function getLikeTextContainer() {
function getDislikeButton() {
return getButtons().children[0].tagName ===
"YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER"
? getButtons().children[0].children[1]
? getButtons().children[0].children[1] === undefined ? document.querySelector("#segmented-dislike-button") : getButtons().children[0].children[1]
: getButtons().children[1];
}
+4 -17
View File
@@ -106,21 +106,19 @@ function isLikesDisabled() {
function isVideoLiked() {
if (isMobile()) {
return (
getLikeButton().querySelector("button").getAttribute("aria-label") ==
"true"
getLikeButton().querySelector("button").getAttribute("aria-label") === "true"
);
}
return getLikeButton().classList.contains("style-default-active");
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"
getDislikeButton().querySelector("button").getAttribute("aria-label") === "true"
);
}
return getDislikeButton().classList.contains("style-default-active");
return getDislikeButton().classList.contains("style-default-active") || getDislikeButton().querySelector('button')?.getAttribute('aria-pressed') === 'true';
}
function getState(storedData) {
@@ -152,17 +150,6 @@ function setDislikes(dislikesCount) {
}
getDislikeTextContainer().innerText = dislikesCount;
try {
let likeButton = document.querySelector("#segmented-like-button > ytd-toggle-button-renderer > yt-button-shape > button > div.cbox.yt-spec-button-shape-next--button-text-content > span")
let dislikeButton = document.querySelector("#segmented-dislike-button > ytd-toggle-button-renderer > yt-button-shape > button")
dislikeButton.appendChild(likeButton.cloneNode(true))
document.querySelector('#segmented-dislike-button > ytd-toggle-button-renderer > yt-button-shape > button').classList.remove('yt-spec-button-shape-next--icon-button')
dislikeButton.lastChild.textContent = dislikesCount
}
finally {
cLg("If you still don't see the dislike, please reach out to us on Github or Discord")
}
} else {
cLog("likes count disabled by creator");
if (isMobile()) {