Sfoglia il codice sorgente

fix: allow num key skip on more elements

Sv443 10 mesi fa
parent
commit
496cdb09e2
1 ha cambiato i file con 5 aggiunte e 7 eliminazioni
  1. 5 7
      src/features/input.ts

+ 5 - 7
src/features/input.ts

@@ -12,7 +12,7 @@ import { createLongBtn, showIconToast } from "../components/index.js";
 import { getAutoLikeDialog } from "../dialogs/index.js";
 import "./input.css";
 
-export const inputIgnoreTagNames = ["INPUT", "TEXTAREA", "SELECT", "BUTTON", "A"];
+export const inputIgnoreTagNames = ["INPUT", "TEXTAREA", "SELECT", "BUTTON", "A", "TP-YT-PAPER-SLIDER"];
 
 //#region arrow key skip
 
@@ -120,8 +120,7 @@ async function switchSite(newDomain: Domain) {
 
 //#region num keys skip
 
-const numKeysIgnoreTagNames = [...inputIgnoreTagNames, "TP-YT-PAPER-TAB"];
-const numKeysIgnoreIds = ["song-media-window"];
+const numKeysIgnoreTagNames = [...inputIgnoreTagNames];
 
 /** Adds the ability to skip to a certain time in the video by pressing a number key (0-9) */
 export async function initNumKeysSkip() {
@@ -133,10 +132,9 @@ export async function initNumKeysSkip() {
     if(isCfgMenuOpen)
       return;
     // discard the event when an unexpected element is currently active or in focus, like when editing a playlist or when the search bar is focused
-    const ignoreElement = numKeysIgnoreIds.includes(document.activeElement?.id ?? "") // video element or player bar active
-      || numKeysIgnoreTagNames.includes(document.activeElement?.tagName ?? ""); // other element active
+    const ignoreElement = numKeysIgnoreTagNames.includes(document.activeElement?.tagName ?? "");
     if((document.activeElement !== document.body && ignoreElement) || ignoreElement)
-      return info("Captured valid key to skip video to, but ignored it since an unexpected element is active:", document.activeElement);
+      return info("Captured valid key to skip video to, but ignored it since this element is currently active:", document.activeElement);
 
     const vidElem = document.querySelector<HTMLVideoElement>(getVideoSelector());
     if(!vidElem)
@@ -151,7 +149,7 @@ export async function initNumKeysSkip() {
   log("Added number key press listener");
 }
 
-//#region auto-like channels
+//#region auto-like vids
 
 let canCompress = false;