Explorar el Código

fix: site switch only on /watch

Sv443 hace 1 año
padre
commit
63429991e0
Se han modificado 1 ficheros con 3 adiciones y 5 borrados
  1. 3 5
      src/features/input.ts

+ 3 - 5
src/features/input.ts

@@ -80,11 +80,6 @@ function onKeyDown(evt: KeyboardEvent) {
 
 /** Initializes the site switch feature */
 export function initSiteSwitch(domain: Domain) {
-  // TODO:
-  // extra features:
-  // - keep video time
-  // - configurable hotkey
-
   document.addEventListener("keydown", (e) => {
     if(e.key === "F9")
       switchSite(domain === "yt" ? "ytm" : "yt");
@@ -95,6 +90,9 @@ export function initSiteSwitch(domain: Domain) {
 /** Switches to the other site (between YT and YTM) */
 async function switchSite(newDomain: Domain) {
   try {
+    if(newDomain === "ytm" && !location.href.includes("/watch"))
+      return warn("Not on a video page, so the site switch is ignored");
+
     let subdomain;
     if(newDomain === "ytm")
       subdomain = "music";