Sv443 před 1 rokem
rodič
revize
60d82ce401
7 změnil soubory, kde provedl 19 přidání a 13 odebrání
  1. 2 2
      dev/numKeysJumpTo.js
  2. 0 0
      dist/BetterYTM.user.js
  3. 9 0
      global.d.ts
  4. 4 2
      src/BetterYTM.user.ts
  5. 3 0
      src/features/input.ts
  6. 0 9
      src/types.d.ts
  7. 1 0
      tsconfig.json

+ 2 - 2
dev/numKeysJumpTo.js

@@ -5,14 +5,14 @@
       return maxWidth;
     return Math.floor(maxWidth / timeSteps) * timeKey;
   }
-    
+
   console.log("scrollY", window.scrollY);
 
   const elem = document.querySelector("tp-yt-paper-progress#sliderBar");
   const rect = getOffset(elem);
   const x = getX(1, rect.width);
   const y = rect.top - rect.height / 2;
-    
+
   console.log(x, y, rect);
 
   const evt = new MouseEvent("mousedown", {

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
dist/BetterYTM.user.js


+ 9 - 0
global.d.ts

@@ -10,3 +10,12 @@ declare module "*.md" {
   const htmlContent: string;
   export default htmlContent;
 }
+
+// generic shim so TS doesn't complain *too* much
+declare global {
+  interface Window {
+    __proto__: {
+      addEventListener: (evt: string, listener: () => unknown, capture?: boolean) => void;
+    }
+  }
+}

+ 4 - 2
src/BetterYTM.user.ts

@@ -18,6 +18,8 @@ import {
 console.log(`${info.name} v${info.version} (${info.lastCommit}) - ${info.namespace}`);
 console.log(`Powered by lots of ambition and my song metadata API: ${geniUrlBase}`);
 
+const domain = getDomain();
+
 async function init() {
   await preInitLayout();
 
@@ -42,7 +44,6 @@ async function onDomLoad() {
   addGlobalStyle("{{GLOBAL_STYLE}}", "global");
 
   const features = await getFeatures();
-  const domain = getDomain();
 
   dbg && console.log(`BetterYTM: Initializing features for domain '${domain}'`);
 
@@ -92,5 +93,6 @@ async function onDomLoad() {
 }
 
 // needs to be called ASAP, before anything async happens
-initBeforeUnloadHook();
+if(domain === "ytm")
+  initBeforeUnloadHook();
 init();

+ 3 - 0
src/features/input.ts

@@ -147,11 +147,13 @@ export function initBeforeUnloadHook() {
   Error.stackTraceLimit = Infinity;
 
   (function(original) {
+    // @ts-ignore
     window.__proto__.addEventListener = function(...args) {
       const [type, listener, ...rest] = args;
       if(type === "beforeunload") {
         return original.apply(this, [
           type,
+          // @ts-ignore
           (...a) => {
             if(beforeUnloadEnabled)
               listener(...a);
@@ -162,6 +164,7 @@ export function initBeforeUnloadHook() {
       else
         return original.apply(this, args);
     };
+    // @ts-ignore
   })(window.__proto__.addEventListener);
 
   getFeatures().then(feats => {

+ 0 - 9
src/types.d.ts

@@ -1,12 +1,3 @@
-// generic shim so TS doesn't complain *too* much
-declare global {
-  interface Window {
-    __proto__: {
-      addEventListener: (evt: string, listener: () => unknown, capture?: boolean) => void;
-    }
-  }
-}
-
 /** Which domain this script is currently running on */
 export type Domain = "yt" | "ytm";
 

+ 1 - 0
tsconfig.json

@@ -33,6 +33,7 @@
     "enable": true,
     "include": [
       "types.d.ts",
+      "global.d.ts",
     ],
   },
 }

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů