소스 검색

ref: remove dbg

Sv443 1 년 전
부모
커밋
2b7475d6a8
4개의 변경된 파일15개의 추가작업 그리고 14개의 파일을 삭제
  1. 1 1
      dist/BetterYTM.user.js
  2. 7 4
      src/features/layout.ts
  3. 6 6
      src/features/menu/menu.ts
  4. 1 3
      src/utils.ts

+ 1 - 1
dist/BetterYTM.user.js

@@ -487,7 +487,7 @@ const scriptInfo = {
     name: GM.info.script.name,
     version: GM.info.script.version,
     namespace: GM.info.script.namespace,
-    lastCommit: "f902649", // assert as generic string instead of union
+    lastCommit: "9c0980d", // assert as generic string instead of union
 };
 
 

+ 7 - 4
src/features/layout.ts

@@ -192,17 +192,20 @@ async function addQueueButtons(queueItem: HTMLElement) {
 
         lyricsUrl = cachedLyricsUrl ?? await getGeniusUrl(artistsSan, songSan);
 
+        const resetImgElem = () => {
+          imgEl.src = getAssetUrl("external/genius.png");
+          imgEl.classList.remove("bytm-spinner");
+        };
+
         if(!cachedLyricsUrl) {
           songInfo.removeAttribute("data-bytm-loading");
 
           // so the new image doesn't "blink"
-          setTimeout(() => {
-            imgEl.src = getAssetUrl("external/genius.png");
-            imgEl.classList.remove("bytm-spinner");
-          }, 100);
+          setTimeout(resetImgElem, 100);
         }
 
         if(!lyricsUrl) {
+          resetImgElem();
           if(confirm("Couldn't find a lyrics page for this song.\nDo you want to open genius.com to manually search for it?"))
             openInNewTab("https://genius.com/search");
           return;

+ 6 - 6
src/features/menu/menu.ts

@@ -57,22 +57,22 @@ export function setActiveTab(tab: keyof typeof tabsSelectors) {
   delete tabs[tab];
   // disable all but new active tab
   for(const [, val] of Object.entries(tabs)) {
-    (document.querySelector(`#${val}-header`) as HTMLElement).dataset.active = "false";
-    (document.querySelector(`#${val}-content`) as HTMLElement).dataset.active = "false";
+    document.querySelector<HTMLElement>(`#${val}-header`)!.dataset.active = "false";
+    document.querySelector<HTMLElement>(`#${val}-content`)!.dataset.active = "false";
   }
   // enable new active tab
-  (document.querySelector(`#${tabsSelectors[tab]}-header`) as HTMLElement).dataset.active = "true";
-  (document.querySelector(`#${tabsSelectors[tab]}-content`) as HTMLElement).dataset.active = "true";
+  document.querySelector<HTMLElement>(`#${tabsSelectors[tab]}-header`)!.dataset.active = "true";
+  document.querySelector<HTMLElement>(`#${tabsSelectors[tab]}-content`)!.dataset.active = "true";
 }
   
 /** Opens the modal menu dialog */
 export function openMenu() {
-  (document.querySelector("#bytm-menu-dialog") as HTMLDialogElement).showModal();
+  document.querySelector<HTMLDialogElement>("#bytm-menu-dialog")?.showModal();
 }
   
 /** Closes the modal menu dialog */
 export function closeMenu() {
-  (document.querySelector("#bytm-menu-dialog") as HTMLDialogElement).close();
+  document.querySelector<HTMLDialogElement>("#bytm-menu-dialog")?.close();
 }
 
 //#MARKER menu tab contents

+ 1 - 3
src/utils.ts

@@ -89,9 +89,8 @@ export function getVideoTime() {
         let videoTime = progElem ? Number(progElem.getAttribute("aria-valuenow")!) : -1;
 
         const mut = new MutationObserver(() => {
-          // .observe() is only called when the element exists
+          // .observe() is only called when the element exists - no need to check for null
           videoTime = Number(document.querySelector<HTMLProgressElement>(pbSelector)!.getAttribute("aria-valuenow")!);
-          dbg("video time changed:", videoTime);
         });
 
         const observe = (progElem: HTMLElement) => {
@@ -102,7 +101,6 @@ export function getVideoTime() {
 
           setTimeout(() => {
             res(videoTime >= 0 && !isNaN(videoTime) ? videoTime : null);
-            dbg("final video time:", videoTime);
           }, 500);
         };