Ver código fonte

feat: auto-like toggle button stuff

Sv443 11 meses atrás
pai
commit
501c03d600
4 arquivos alterados com 22 adições e 0 exclusões
  1. 1 0
      src/config.ts
  2. 6 0
      src/features/index.ts
  3. 13 0
      src/features/input.ts
  4. 2 0
      src/types.ts

+ 1 - 0
src/config.ts

@@ -61,6 +61,7 @@ export const migrations: DataMigrationsDict = {
   // 5 -> 6 (v2.1)
   6: (oldData: FeatureConfig) => useDefaultConfig(oldData, [
     "autoLikeChannels", "openAutoLikeChannelsDialog",
+    "autoLikeChannelToggleButtons",
   ]),
   // TODO: once advanced filtering is fully implemented, clear cache on migration to fv6
   // 6 -> 7 (v2.x)

+ 6 - 0
src/features/index.ts

@@ -457,6 +457,12 @@ export const featInfo = {
     category: "input",
     click: () => getAutoLikeChannelsDialog().then(d => d.open()),
   },
+  autoLikeChannelToggleButtons: {
+    type: "toggle",
+    category: "input",
+    default: true,
+    textAdornment: adornments.reloadRequired,
+  },
 
   //#region lyrics
   geniusLyrics: {

+ 13 - 0
src/features/input.ts

@@ -204,6 +204,14 @@ export async function initAutoLikeChannels() {
           }
         }, 5_000);
       });
+
+      if(getFeatures().autoLikeChannelToggleButtons) {
+        // TODO:
+        const artistEls = document.querySelectorAll<HTMLElement>(".content-info-wrapper .subtitle a.yt-formatted-string[href]");
+
+        for(const artistEl of artistEls)
+          addAutoLikeToggleBtn(artistEl);
+      }
     }
     else if(getDomain() === "yt") {
       // TODO:
@@ -213,3 +221,8 @@ export async function initAutoLikeChannels() {
     error("Error while auto-liking channel:", err);
   }
 }
+
+function addAutoLikeToggleBtn(sibling: HTMLElement) {
+  // TODO:
+  void sibling;
+}

+ 2 - 0
src/types.ts

@@ -423,6 +423,8 @@ export interface FeatureConfig {
   autoLikeChannels: boolean;
   /** Opens the auto-like channels management dialog */
   openAutoLikeChannelsDialog: undefined;
+  /** Whether to show toggle buttons in the media controls to enable/disable auto-liking for that channel */
+  autoLikeChannelToggleButtons: boolean;
 
   //#region lyrics
   /** Add a button to the media controls to open the current song's lyrics on genius.com in a new tab */