Browse Source

manually added channel categories; formatted code

Brandon Wong 1 year ago
parent
commit
7f18c6c57b
1 changed files with 55 additions and 18 deletions
  1. 55 18
      popup/popup.js

+ 55 - 18
popup/popup.js

@@ -34,7 +34,21 @@ document.addEventListener("alpine:init", () => {
 
     // Save channel properties
     selectedCategory: "FOR BOTH", // Currently selected category
-    availableCategories: ["FOR BOTH", "CHANNELS", "CREATIVE"], // Available categories
+    availableCategories: [
+      "FOR BOTH",
+      "CHANNELS",
+      "SCIFI",
+      "POLI/REL",
+      "REAL ESTATE",
+      "HELICOPTER",
+      "SAILING",
+      "VAN LIFE",
+      "BLOCKCHAIN",
+      "MAKING",
+      "DESIGN",
+      "TECH CONF",
+      "CREATIVE",
+    ], // Available categories
     curlCommand: "", // Generated curl command
     checkInterval: 14, // Check interval in days
 
@@ -95,8 +109,12 @@ document.addEventListener("alpine:init", () => {
             .map((video, index) => ({
               ...video,
               originalIndex: currentIndex + index,
-              doneButtonText: video.status === "done" ? "Remove Done Status" : "Mark as Done",
-              isNonContiguousDone: this.isNonContiguousDone(playlistName, currentIndex + index),
+              doneButtonText:
+                video.status === "done" ? "Remove Done Status" : "Mark as Done",
+              isNonContiguousDone: this.isNonContiguousDone(
+                playlistName,
+                currentIndex + index,
+              ),
             }));
 
           return {
@@ -117,10 +135,16 @@ document.addEventListener("alpine:init", () => {
       ) {
         this.currentPlaylistVideos = [];
       } else {
-        this.currentPlaylistVideos = this.playlists[this.currentPlaylistName].map((video, index) => ({
+        this.currentPlaylistVideos = this.playlists[
+          this.currentPlaylistName
+        ].map((video, index) => ({
           ...video,
-          doneButtonText: video.status === "done" ? "Remove Done Status" : "Mark as Done",
-          isNonContiguousDone: this.isNonContiguousDone(this.currentPlaylistName, index),
+          doneButtonText:
+            video.status === "done" ? "Remove Done Status" : "Mark as Done",
+          isNonContiguousDone: this.isNonContiguousDone(
+            this.currentPlaylistName,
+            index,
+          ),
         }));
       }
     },
@@ -146,7 +170,8 @@ document.addEventListener("alpine:init", () => {
           this.currentTab = tabs[0];
           const url = new URL(this.currentTab.url);
           this.isCurrentTabYoutube = url.hostname === "www.youtube.com";
-          this.isCurrentTabChannelPage = this.isCurrentTabYoutube && url.pathname.includes("/videos");
+          this.isCurrentTabChannelPage =
+            this.isCurrentTabYoutube && url.pathname.includes("/videos");
           this.updateAddCurrentPageButtonText();
           this.updateCurlCommand();
         }
@@ -172,7 +197,8 @@ document.addEventListener("alpine:init", () => {
 
     updateCurlCommand() {
       if (!this.currentTab || !this.isCurrentTabChannelPage) {
-        this.curlCommand = "This feature is only available on YouTube channel pages (/videos).";
+        this.curlCommand =
+          "This feature is only available on YouTube channel pages (/videos).";
         return;
       }
 
@@ -436,7 +462,7 @@ document.addEventListener("alpine:init", () => {
     async toggleVideoDoneStatus(playlistName, index) {
       const playlists = JSON.parse(JSON.stringify(this.playlists));
       const playlist = [...playlists[playlistName]];
-      const video = {...playlist[index]};
+      const video = { ...playlist[index] };
 
       // Toggle the done status
       if (video.status === "done") {
@@ -512,13 +538,16 @@ document.addEventListener("alpine:init", () => {
         try {
           const tabsResult = await browser.tabs.query({});
           openTabs = tabsResult
-            .filter(tab => tab.url &&
-              !tab.url.startsWith('moz-extension://') &&
-              !tab.url.startsWith('about:') &&
-              !tab.url.startsWith('chrome://'))
-            .map(tab => ({
+            .filter(
+              (tab) =>
+                tab.url &&
+                !tab.url.startsWith("moz-extension://") &&
+                !tab.url.startsWith("about:") &&
+                !tab.url.startsWith("chrome://"),
+            )
+            .map((tab) => ({
               url: tab.url,
-              title: tab.title || 'Untitled'
+              title: tab.title || "Untitled",
             }));
         } catch (error) {
           console.warn("Could not retrieve open tabs:", error);
@@ -571,7 +600,11 @@ document.addEventListener("alpine:init", () => {
 
     isNonContiguousDone(playlistName, videoIndex) {
       const playlist = this.playlists[playlistName];
-      if (!playlist || !playlist[videoIndex] || playlist[videoIndex].status !== "done") {
+      if (
+        !playlist ||
+        !playlist[videoIndex] ||
+        playlist[videoIndex].status !== "done"
+      ) {
         return false;
       }
 
@@ -596,7 +629,8 @@ document.addEventListener("alpine:init", () => {
     },
 
     isVideoDone(playlistName, index) {
-      const video = this.playlists[playlistName] && this.playlists[playlistName][index];
+      const video =
+        this.playlists[playlistName] && this.playlists[playlistName][index];
       return video && video.status === "done";
     },
 
@@ -610,7 +644,10 @@ document.addEventListener("alpine:init", () => {
           "current-video": this.isCurrentVideo(playlistName, index),
           "done-video":
             this.isDoneVideo(playlistName, index) && video.status === "done",
-          "non-contiguous-done-video": this.isNonContiguousDone(playlistName, index),
+          "non-contiguous-done-video": this.isNonContiguousDone(
+            playlistName,
+            index,
+          ),
         };
       },
     },