fix get count dislikes on mobile version of youtube (#888)

* fix (ryd.content.script.js, events.js) fix get count likes on mobile version of yt (tested on android device)

* fix fallback solution for get dislikes
This commit is contained in:
Roman Ushakov authored and GitHub committed 2023-03-10 19:40:57 +01:00
1 parent 9a44acf89d
commit a6c945a4eb
2 files changed
+19 -8

No files matched your search

+15 -6
View File
@@ -44,18 +44,27 @@ import {
initExtConfig();
let jsInitChecktimer = null;
let isSetInitialStateDone = false;
function setEventListeners(evt) {
function checkForJS_Finish() {
if (isShorts() || (getButtons()?.offsetParent && isVideoLoaded())) {
addLikeDislikeEventListener();
setInitialState();
getBrowser().storage.onChanged.addListener(storageChangeHandler);
clearInterval(jsInitChecktimer);
jsInitChecktimer = null;
try {
if (isShorts() || (getButtons()?.offsetParent && isVideoLoaded())) {
addLikeDislikeEventListener();
setInitialState();
isSetInitialStateDone = true;
getBrowser().storage.onChanged.addListener(storageChangeHandler);
clearInterval(jsInitChecktimer);
jsInitChecktimer = null;
}
} catch(exception) {
if(!isSetInitialStateDone) {
setInitialState();
}
}
}
jsInitChecktimer = setInterval(checkForJS_Finish, 111);
}
+4 -2
View File
@@ -85,9 +85,11 @@ function dislikeClicked() {
function addLikeDislikeEventListener() {
if (!window.returnDislikeButtonlistenersSet) {
getLikeButton().addEventListener("click", likeClicked);
getDislikeButton().addEventListener("click", dislikeClicked);
getLikeButton().addEventListener("touchstart", likeClicked);
getLikeButton().addEventListener("touchstart", dislikeClicked);
if(getDislikeButton()) {
getDislikeButton().addEventListener("click", dislikeClicked);
getDislikeButton().addEventListener("touchstart", dislikeClicked);
}
window.returnDislikeButtonlistenersSet = true;
}
}