mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-02 10:52:20 +01:00
improve rateBar selector
This commit is contained in:
1 parent
7db9d9d30d
commit
b5382bab78
1 file changed
+13
-9
@@ -7,11 +7,17 @@ import {
|
|||||||
isRoundedDesign,
|
isRoundedDesign,
|
||||||
isShorts,
|
isShorts,
|
||||||
} from "./state";
|
} from "./state";
|
||||||
import { cLog, getColorFromTheme } from "./utils";
|
import { cLog, getColorFromTheme, isInViewport } from "./utils";
|
||||||
|
|
||||||
function createRateBar(likes, dislikes) {
|
function createRateBar(likes, dislikes) {
|
||||||
|
let rateBar = document.getElementById("ryd-bar-container");
|
||||||
if (!isLikesDisabled()) {
|
if (!isLikesDisabled()) {
|
||||||
let rateBar = document.getElementById("ryd-bar-container");
|
// sometimes rate bar is hidden
|
||||||
|
if(rateBar && !isInViewport(rateBar)){
|
||||||
|
cLog('create rateBar remove old')
|
||||||
|
rateBar.remove();
|
||||||
|
rateBar = null;
|
||||||
|
}
|
||||||
|
|
||||||
const widthPx =
|
const widthPx =
|
||||||
getLikeButton().clientWidth +
|
getLikeButton().clientWidth +
|
||||||
@@ -55,11 +61,10 @@ function createRateBar(likes, dislikes) {
|
|||||||
colorLikeStyle = "; background-color: " + getColorFromTheme(true);
|
colorLikeStyle = "; background-color: " + getColorFromTheme(true);
|
||||||
colorDislikeStyle = "; background-color: " + getColorFromTheme(false);
|
colorDislikeStyle = "; background-color: " + getColorFromTheme(false);
|
||||||
}
|
}
|
||||||
|
let actions = isNewDesign() && getButtons().id === "top-level-buttons-computed"
|
||||||
|
? getButtons() : document.getElementById("menu-container");
|
||||||
(
|
(
|
||||||
document.getElementById(
|
actions || document.querySelector("ytm-slim-video-action-bar-renderer")
|
||||||
isNewDesign() ? "top-level-buttons-computed" : "menu-container"
|
|
||||||
) || document.querySelector("ytm-slim-video-action-bar-renderer")
|
|
||||||
).insertAdjacentHTML(
|
).insertAdjacentHTML(
|
||||||
"beforeend",
|
"beforeend",
|
||||||
`
|
`
|
||||||
@@ -112,9 +117,8 @@ function createRateBar(likes, dislikes) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cLog("removing bar");
|
cLog("removing bar");
|
||||||
let ratebar = document.getElementById("ryd-bar-container");
|
if (rateBar) {
|
||||||
if (ratebar) {
|
rateBar.parentNode.removeChild(rateBar);
|
||||||
ratebar.parentNode.removeChild(ratebar);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user