Ver código fonte

fix: add title attrib for remove from queue btn

Sv443 1 ano atrás
pai
commit
6e45b38f66
2 arquivos alterados com 48 adições e 26 exclusões
  1. 24 13
      dist/BetterYTM.user.js
  2. 24 13
      src/features/layout.ts

+ 24 - 13
dist/BetterYTM.user.js

@@ -480,7 +480,7 @@ const scriptInfo = Object.freeze({
     name: GM.info.script.name,
     version: GM.info.script.version,
     namespace: GM.info.script.namespace,
-    lastCommit: "049bc75", // assert as generic string instead of union
+    lastCommit: "57129c1", // assert as generic string instead of union
 });
 
 
@@ -1029,9 +1029,9 @@ function initQueueButtons() {
  */
 function addQueueButtons(queueItem) {
     return __awaiter(this, void 0, void 0, function* () {
+        //#SECTION general queue item stuff
         const queueBtnsCont = document.createElement("div");
         queueBtnsCont.className = "bytm-queue-btn-container";
-        //#SECTION lyrics
         const songInfo = queueItem.querySelector(".song-info");
         if (!songInfo)
             return false;
@@ -1040,12 +1040,17 @@ function addQueueButtons(queueItem) {
         const artist = artistEl.innerText;
         if (!song || !artist)
             return false;
+        //#SECTION lyrics btn
         const lyricsBtnElem = (0,_lyrics__WEBPACK_IMPORTED_MODULE_5__.createLyricsBtn)(undefined, false);
         {
-            lyricsBtnElem.title = "Open this song's lyrics in a new tab";
-            lyricsBtnElem.style.visibility = "initial";
-            lyricsBtnElem.style.display = "inline-flex";
-            lyricsBtnElem.style.pointerEvents = "initial";
+            Object.assign(lyricsBtnElem, {
+                title: "Open this song's lyrics in a new tab",
+                style: {
+                    visibility: "initial",
+                    display: "inline-flex",
+                    pointerEvents: "initial",
+                },
+            });
             lyricsBtnElem.addEventListener("click", () => __awaiter(this, void 0, void 0, function* () {
                 let lyricsUrl;
                 const artistsSan = (0,_lyrics__WEBPACK_IMPORTED_MODULE_5__.sanitizeArtists)(artist);
@@ -1071,15 +1076,20 @@ function addQueueButtons(queueItem) {
                 lyricsUrl && (0,_utils__WEBPACK_IMPORTED_MODULE_2__.openInNewTab)(lyricsUrl);
             }));
         }
-        //#SECTION delete from queue
+        //#SECTION delete from queue btn
         const deleteBtnElem = document.createElement("a");
         {
-            deleteBtnElem.className = "ytmusic-player-bar bytm-delete-from-queue bytm-generic-btn";
-            deleteBtnElem.role = "button";
-            deleteBtnElem.target = "_blank";
-            deleteBtnElem.rel = "noopener noreferrer";
-            deleteBtnElem.style.visibility = "initial";
-            deleteBtnElem.style.display = "inline-flex";
+            Object.assign(deleteBtnElem, {
+                title: "Remove this song from the queue",
+                className: "ytmusic-player-bar bytm-delete-from-queue bytm-generic-btn",
+                role: "button",
+                target: "_blank",
+                rel: "noopener noreferrer",
+                style: {
+                    visibility: "initial",
+                    display: "inline-flex",
+                },
+            });
             deleteBtnElem.addEventListener("click", () => __awaiter(this, void 0, void 0, function* () {
                 // container of the queue item popup menu - element gets reused for every queue item
                 let queuePopupCont = document.querySelector("ytmusic-app ytmusic-popup-container tp-yt-iron-dropdown");
@@ -1110,6 +1120,7 @@ function addQueueButtons(queueItem) {
             imgElem.src = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getAssetUrl)("close.png"); // TODO: make own icon for this
             deleteBtnElem.appendChild(imgElem);
         }
+        //#SECTION append elements to DOM
         queueBtnsCont.appendChild(lyricsBtnElem);
         queueBtnsCont.appendChild(deleteBtnElem);
         songInfo.appendChild(queueBtnsCont);

+ 24 - 13
src/features/layout.ts

@@ -113,11 +113,10 @@ export function initQueueButtons() {
  * @param queueItem The element with tagname `ytmusic-player-queue-item` to add queue buttons to
  */
 async function addQueueButtons(queueItem: HTMLElement) {
+  //#SECTION general queue item stuff
   const queueBtnsCont = document.createElement("div");
   queueBtnsCont.className = "bytm-queue-btn-container";
 
-  //#SECTION lyrics
-
   const songInfo = queueItem.querySelector(".song-info") as HTMLElement;
   if(!songInfo)
     return false;
@@ -128,12 +127,17 @@ async function addQueueButtons(queueItem: HTMLElement) {
   if(!song || !artist)
     return false;
 
+  //#SECTION lyrics btn
   const lyricsBtnElem = createLyricsBtn(undefined, false);
   {
-    lyricsBtnElem.title = "Open this song's lyrics in a new tab";
-    lyricsBtnElem.style.visibility = "initial";
-    lyricsBtnElem.style.display = "inline-flex";
-    lyricsBtnElem.style.pointerEvents = "initial";
+    Object.assign(lyricsBtnElem, {
+      title: "Open this song's lyrics in a new tab",
+      style: {
+        visibility: "initial",
+        display: "inline-flex",
+        pointerEvents: "initial",
+      },
+    });
 
     lyricsBtnElem.addEventListener("click", async () => {
       let lyricsUrl;
@@ -167,15 +171,20 @@ async function addQueueButtons(queueItem: HTMLElement) {
     });
   }
 
-  //#SECTION delete from queue
+  //#SECTION delete from queue btn
   const deleteBtnElem = document.createElement("a");
   {
-    deleteBtnElem.className = "ytmusic-player-bar bytm-delete-from-queue bytm-generic-btn";
-    deleteBtnElem.role = "button";
-    deleteBtnElem.target = "_blank";
-    deleteBtnElem.rel = "noopener noreferrer";
-    deleteBtnElem.style.visibility = "initial";
-    deleteBtnElem.style.display = "inline-flex";
+    Object.assign(deleteBtnElem, {
+      title: "Remove this song from the queue",
+      className: "ytmusic-player-bar bytm-delete-from-queue bytm-generic-btn",
+      role: "button",
+      target: "_blank",
+      rel: "noopener noreferrer",
+      style: {
+        visibility: "initial",
+        display: "inline-flex",
+      },
+    });
 
     deleteBtnElem.addEventListener("click", async () => {
       // container of the queue item popup menu - element gets reused for every queue item
@@ -216,6 +225,8 @@ async function addQueueButtons(queueItem: HTMLElement) {
     deleteBtnElem.appendChild(imgElem);
   }
 
+  //#SECTION append elements to DOM
+
   queueBtnsCont.appendChild(lyricsBtnElem);
   queueBtnsCont.appendChild(deleteBtnElem);