mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-29 17:37:54 +01:00
Merge branch 'main' into fix-like-dislike-bar-offset
This commit is contained in:
39 files changed
+873
-51
No files matched your search
@@ -58,14 +58,12 @@ function createRateBar(likes, dislikes) {
|
||||
|
||||
(
|
||||
document.getElementById(
|
||||
isNewDesign() ? "actions-inner" : "menu-container"
|
||||
isNewDesign() ? "top-level-buttons-computed" : "menu-container"
|
||||
) || document.querySelector("ytm-slim-video-action-bar-renderer")
|
||||
).insertAdjacentHTML(
|
||||
"beforeend",
|
||||
`
|
||||
<div class="ryd-tooltip" style="width: ${widthPx}px${
|
||||
isNewDesign() ? "; margin-bottom: -2px" : ""
|
||||
}">
|
||||
<div class="ryd-tooltip ryd-tooltip-${isNewDesign() ? "new" : "old"}-design" style="width: ${widthPx}px">
|
||||
<div class="ryd-tooltip-bar-container">
|
||||
<div
|
||||
id="ryd-bar-container"
|
||||
|
||||
@@ -24,7 +24,7 @@ function getButtons() {
|
||||
//--- If Menu Element Is Displayed: ---//
|
||||
if (document.getElementById("menu-container")?.offsetParent === null) {
|
||||
return document.querySelector("ytd-menu-renderer.ytd-watch-metadata > div");
|
||||
//--- If Menu Element Isnt Displayed: ---//
|
||||
//--- If Menu Element Isn't Displayed: ---//
|
||||
} else {
|
||||
return document
|
||||
.getElementById("menu-container")
|
||||
@@ -42,7 +42,8 @@ function getLikeButton() {
|
||||
function getLikeTextContainer() {
|
||||
return (
|
||||
getLikeButton().querySelector("#text") ??
|
||||
getLikeButton().getElementsByTagName("yt-formatted-string")[0]
|
||||
getLikeButton().getElementsByTagName("yt-formatted-string")[0] ??
|
||||
getLikeButton().querySelector("span[role='text']")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,11 +135,14 @@ function getState(storedData) {
|
||||
|
||||
//--- Sets The Likes And Dislikes Values ---//
|
||||
function setLikes(likesCount) {
|
||||
cLog(`SET likes ${likesCount}`)
|
||||
getLikeTextContainer().innerText = likesCount;
|
||||
}
|
||||
|
||||
function setDislikes(dislikesCount) {
|
||||
cLog(`SET dislikes ${dislikesCount}`)
|
||||
getDislikeTextContainer()?.removeAttribute("is-empty");
|
||||
getDislikeTextContainer()?.removeAttribute('is-empty');
|
||||
if (!isLikesDisabled()) {
|
||||
if (isMobile()) {
|
||||
getButtons().children[1].querySelector(
|
||||
@@ -163,14 +166,17 @@ function setDislikes(dislikesCount) {
|
||||
function getLikeCountFromButton() {
|
||||
try {
|
||||
if (isShorts()) {
|
||||
//Youtube Shorts don't work with this query. It's not nessecary; we can skip it and still see the results.
|
||||
//Youtube Shorts don't work with this query. It's not necessary; 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, "");
|
||||
|
||||
let likeButton = getLikeButton()
|
||||
.querySelector("yt-formatted-string#text") ??
|
||||
getLikeButton().querySelector("button");
|
||||
|
||||
let likesStr = likeButton.getAttribute("aria-label")
|
||||
.replace(/\D/g, "");
|
||||
return likesStr.length > 0 ? parseInt(likesStr) : false;
|
||||
} catch {
|
||||
return false;
|
||||
@@ -191,7 +197,7 @@ function processResponse(response, storedData) {
|
||||
createRateBar(storedData.likes, storedData.dislikes);
|
||||
if (extConfig.coloredThumbs === true) {
|
||||
if (isShorts()) {
|
||||
// for shorts, leave deactived buttons in default color
|
||||
// for shorts, leave deactivated buttons in default color
|
||||
let shortLikeButton = getLikeButton().querySelector(
|
||||
"tp-yt-paper-button#button"
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user