mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-01 02:17:53 +01:00
Extension fix - disappearing dislike counter (#999)
* Fix rate bar jumping around in width * Fix disappearing dislike counter * Fix disappearing dislike count on button focus/unfocus by @kokonguyen191 * Fix event listeners being thrown away by YouTube in some cases * Extension fix for disappearing dislikes while smartimations play * Check if smartimationContainer exists
This commit is contained in:
1 parent
2f2153ed37
commit
6791543617
5 files changed
+65
-42
No files matched your search
@@ -11,9 +11,11 @@ import {
|
||||
getVideoId,
|
||||
cLog,
|
||||
numberFormat,
|
||||
getColorFromTheme, querySelector
|
||||
getColorFromTheme,
|
||||
querySelector,
|
||||
localize,
|
||||
createObserver
|
||||
} from './utils';
|
||||
import { localize } from "./utils";
|
||||
import { createStarRating } from "./starRating";
|
||||
|
||||
//TODO: Do not duplicate here and in ryd.background.js
|
||||
@@ -82,20 +84,13 @@ function isRoundedDesign() {
|
||||
return querySelector(extConfig.selectors.roundedDesign) !== null;
|
||||
}
|
||||
|
||||
let mutationObserver = new Object();
|
||||
let shortsObserver = null;
|
||||
|
||||
if (isShorts() && mutationObserver.exists !== true) {
|
||||
cLog("initializing mutation observer");
|
||||
mutationObserver.options = {
|
||||
childList: false,
|
||||
attributes: true,
|
||||
subtree: false,
|
||||
};
|
||||
mutationObserver.exists = true;
|
||||
mutationObserver.observer = new MutationObserver(function (
|
||||
mutationList,
|
||||
observer
|
||||
) {
|
||||
if (isShorts() && !shortsObserver) {
|
||||
cLog("Initializing shorts mutation observer");
|
||||
shortsObserver = createObserver({
|
||||
attributes: true
|
||||
}, (mutationList) => {
|
||||
mutationList.forEach((mutation) => {
|
||||
if (
|
||||
mutation.type === "attributes" &&
|
||||
@@ -114,7 +109,7 @@ if (isShorts() && mutationObserver.exists !== true) {
|
||||
return;
|
||||
}
|
||||
cLog(
|
||||
"unexpected mutation observer event: " + mutation.target + mutation.type
|
||||
"Unexpected mutation observer event: " + mutation.target + mutation.type
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -236,14 +231,8 @@ function processResponse(response, storedData) {
|
||||
if (shortDislikeButton.getAttribute("aria-pressed") === "true") {
|
||||
shortDislikeButton.style.color = getColorFromTheme(false);
|
||||
}
|
||||
mutationObserver.observer.observe(
|
||||
shortLikeButton,
|
||||
mutationObserver.options
|
||||
);
|
||||
mutationObserver.observer.observe(
|
||||
shortDislikeButton,
|
||||
mutationObserver.options
|
||||
);
|
||||
shortsObserver.observe(shortLikeButton);
|
||||
shortsObserver.observe(shortDislikeButton);
|
||||
} else {
|
||||
getLikeButton().style.color = getColorFromTheme(true);
|
||||
getDislikeButton().style.color = getColorFromTheme(false);
|
||||
|
||||
Reference in new issue
Block a user