Explorar o código

Mobile Extensions: Supports YouTube Shorts

RyanBurgert219 %!s(int64=3) %!d(string=hai) anos
pai
achega
73e58beac4

+ 2 - 2
Extensions/combined/ryd.content-script.js

@@ -37,11 +37,11 @@ let jsInitChecktimer = null;
 function setEventListeners(evt) {
   function checkForJS_Finish() {
     if (isShorts() || getButtons()?.offsetParent && isVideoLoaded()) {
-      clearInterval(jsInitChecktimer);
-      jsInitChecktimer = null;
       addLikeDislikeEventListener();
       setInitialState();
       getBrowser().storage.onChanged.addListener(storageChangeHandler);
+      clearInterval(jsInitChecktimer);
+      jsInitChecktimer = null;
     }
   }
 

+ 1 - 1
Extensions/combined/src/buttons.js

@@ -4,7 +4,7 @@ import { isInViewport } from "./utils";
 function getButtons() {
   //---   If Watching Youtube Shorts:   ---//
   if(isShorts()) {
-    let elements=document.querySelectorAll("#like-button > ytd-like-button-renderer")
+    let elements=document.querySelectorAll(isMobile() ? "ytm-like-button-renderer" : "#like-button > ytd-like-button-renderer"); 
     for(let element of elements) {
       //Youtube Shorts can have multiple like/dislike buttons when scrolling through videos
       //However, only one of them should be visible (no matter how you zoom)

+ 2 - 0
Extensions/combined/src/events.js

@@ -100,6 +100,8 @@ function addLikeDislikeEventListener() {
   if (!window.returnDislikeButtonlistenersSet) {
     buttons.children[0].addEventListener("click", likeClicked);
     buttons.children[1].addEventListener("click", dislikeClicked);
+    buttons.children[0].addEventListener("touchstart", likeClicked);
+    buttons.children[1].addEventListener("touchstart", dislikeClicked);
     window.returnDislikeButtonlistenersSet = true;
   }
 }