Procházet zdrojové kódy

ref: remove all references to NodeJS types

Sven před 10 měsíci
rodič
revize
43ee1d5c14

+ 1 - 1
src/components/toast.ts

@@ -29,7 +29,7 @@ type IconToastProps = ToastProps & (
   }
 );
 
-let timeout: NodeJS.Timeout | undefined;
+let timeout: ReturnType<typeof setTimeout> | undefined;
 
 /** Shows a toast message with an icon */
 export async function showIconToast({

+ 4 - 5
src/dialogs/autoLike.ts

@@ -3,7 +3,7 @@ import { compressionSupported, error, getDomain, log, onInteraction, parseChanne
 import { BytmDialog, createCircularBtn, createToggleInput, showToast } from "../components/index.js";
 import { autoLikeStore, initAutoLikeStore } from "../features/index.js";
 import { siteEvents } from "../siteEvents.js";
-import { ExImDialog } from "../components/ExportImportDialog.js";
+import { ExImDialog } from "../components/ExImDialog.js";
 import { compressionFormat } from "../constants.js";
 import type { AutoLikeData } from "../types.js";
 import "./autoLike.css";
@@ -72,10 +72,9 @@ export async function getAutoLikeDialog() {
           error("Couldn't import auto-like channels data:", err);
         }
       },
-      trKeyTitle: "auto_like_export_import_title",
-      trKeyDescImport: "auto_like_import_desc",
-      trKeyDescExport: "auto_like_export_desc",
-      dataHidden: false,
+      title: () => t("auto_like_export_import_title"),
+      descImport: () => t("auto_like_import_desc"),
+      descExport: () => t("auto_like_export_desc"),
     });
   }
 

+ 1 - 1
src/features/behavior.ts

@@ -152,7 +152,7 @@ async function restVidRestoreTime() {
 }
 
 let lastSongTime = -1;
-let remVidCheckTimeout: NodeJS.Timeout | undefined;
+let remVidCheckTimeout: ReturnType<typeof setTimeout> | undefined;
 
 /** Only call once as this calls itself after a timeout! - Updates the currently playing video's entry in GM storage */
 async function restVidStartUpdateLoop() {

+ 2 - 2
src/features/input.ts

@@ -190,7 +190,7 @@ export async function initAutoLike() {
     canCompress = await compressionSupported();
     await initAutoLikeStore();
     if(getDomain() === "ytm") {
-      let timeout: NodeJS.Timeout;
+      let timeout: ReturnType<typeof setTimeout>;
       siteEvents.on("songTitleChanged", () => {
         timeout && clearTimeout(timeout);
         timeout = setTimeout(() => {
@@ -250,7 +250,7 @@ export async function initAutoLike() {
       });
     }
     else if(getDomain() === "yt") {
-      let timeout: NodeJS.Timeout;
+      let timeout: ReturnType<typeof setTimeout>;
       siteEvents.on("watchIdChanged", () => {
         timeout && clearTimeout(timeout);
         if(!location.pathname.startsWith("/watch"))

+ 2 - 2
src/features/layout.ts

@@ -726,7 +726,7 @@ export async function initShowVotes() {
           return error("Couldn't get watch ID while initializing showVotes");
         const voteObj = await fetchVideoVotes(watchId);
         if(!voteObj || !("likes" in voteObj) || !("dislikes" in voteObj) || !("rating" in voteObj))
-          return error("Couldn't fetch votes from ReturnYouTubeDislikes API");
+          return error("Couldn't fetch votes from the Return YouTube Dislike API");
 
         getFeature("showVotes") && addVoteNumbers(voteCont, voteObj);
       }
@@ -748,7 +748,7 @@ export async function initShowVotes() {
 
     const voteObj = await fetchVideoVotes(watchId);
     if(!voteObj || !("likes" in voteObj) || !("dislikes" in voteObj) || !("rating" in voteObj))
-      return error("Couldn't fetch votes from ReturnYouTubeDislikes API");
+      return error("Couldn't fetch votes from the Return YouTube Dislike API");
 
     labelLikes.dataset.watchId = getWatchId() ?? "";
     labelLikes.textContent = formatVoteNumber(voteObj.likes);

+ 5 - 6
src/menu/menu_old.ts

@@ -6,10 +6,10 @@ import { error, getResourceUrl, info, log, resourceToHTMLString, getLocale, hasK
 import { emitSiteEvent, siteEvents } from "../siteEvents.js";
 import { getChangelogDialog, getFeatHelpDialog } from "../dialogs/index.js";
 import type { FeatureCategory, FeatureKey, FeatureConfig, HotkeyObj, FeatureInfo } from "../types.js";
-import "./menu_old.css";
 import { BytmDialog, ExImDialog, createHotkeyInput, createToggleInput, openDialogs, setCurrentDialogId } from "../components/index.js";
 import { emitInterface } from "../interface.js";
 import pkg from "../../package.json" with { type: "json" };
+import "./menu_old.css";
 
 //#region create menu
 
@@ -17,7 +17,7 @@ let isCfgMenuMounted = false;
 export let isCfgMenuOpen = false;
 
 /** Threshold in pixels from the top of the options container that dictates for how long the scroll indicator is shown */
-const scrollIndicatorOffsetThreshold = 30;
+const scrollIndicatorOffsetThreshold = 50;
 let scrollIndicatorEnabled = true;
 /** Locale at the point of initializing the config menu */
 let initLocale: string | undefined;
@@ -237,10 +237,9 @@ async function mountCfgMenu() {
         alert(t("import_error_invalid"));
       }
     },
-    trKeyTitle: "bytm_config_export_import_title",
-    trKeyDescImport: "bytm_config_import_desc",
-    trKeyDescExport: "bytm_config_export_desc",
-    dataHidden: false,
+    title: () => t("bytm_config_export_import_title"),
+    descImport: () => t("bytm_config_import_desc"),
+    descExport: () => t("bytm_config_export_desc"),
   });
 
   const exportImportBtn = document.createElement("button");

+ 2 - 2
src/utils/xhr.ts

@@ -57,10 +57,10 @@ export async function fetchCss(key: ResourceKey & `css-${string}`) {
   }
 }
 
-/** Cache for the vote data of YouTube videos to prevent unnecessary requests */
+/** Cache for the vote data of YouTube videos to prevent some unnecessary requests */
 const voteCache = new Map<string, VideoVotesObj>();
 /** Time-to-live for the vote cache in milliseconds */
-const voteCacheTTL = 1000 * 60 * 5;
+const voteCacheTTL = 1000 * 60 * 10;
 
 /**
  * Fetches the votes object for a YouTube video from the [Return YouTube Dislike API.](https://returnyoutubedislike.com/docs)