Ver código fonte

fix: arrow key skip

Sven 1 ano atrás
pai
commit
b8d71b8217
3 arquivos alterados com 12 adições e 3 exclusões
  1. 9 1
      README.md
  2. 2 2
      src/features/input.ts
  3. 1 0
      src/tools/post-build.ts

+ 9 - 1
README.md

@@ -44,7 +44,15 @@ Once you have the extension, click this button to install the userscript:
 <!-- <a href="https://github.com/Sv443/BetterYTM/raw/main/BetterYTM.user.js" target="_blank"><img src="https://img.shields.io/badge/Install-%E2%96%BA-039e10" height="24"></a> -->
 <a href="https://github.com/Sv443/BetterYTM/raw/main/BetterYTM.user.js" target="_blank"><img src="https://img.shields.io/badge/Install-%E2%96%BC-039e10" height="24"></a>
 
-<br><br>
+<br>
+
+<sub>
+
+Note: the `unsafeWindow` grant is required due to limitations in some browsers, [see this issue for more info.](https://github.com/Sv443/BetterYTM/issues/18#show_issue)
+
+</sub>
+
+<br><br><br>
 
 ### Development:
 | Command | Description |

+ 2 - 2
src/features/input.ts

@@ -35,7 +35,7 @@ function onKeyDown(evt: KeyboardEvent) {
       cancelable: true,
       isTrusted: true,
       repeat: false,
-      view: window,
+      view: unsafeWindow,
     };
 
     let invalidKey = false;
@@ -118,7 +118,7 @@ function switchSite(newDomain: Domain) {
     console.info(`BetterYTM - switching to domain '${newDomain}' at ${url}`);
 
     disableBeforeUnload();
-    setImmediate(() => location.href = url);
+    setTimeout(() => { location.href = url; }, 0);
   }
   catch(err) {
     console.error("Error while switching site:", err);

+ 1 - 0
src/tools/post-build.ts

@@ -31,6 +31,7 @@ ${matchDirectives}\
 // @run-at          document-start
 // @grant           GM.getValue
 // @grant           GM.setValue
+// @grant           unsafeWindow
 // @connect         self
 // @connect         youtube.com
 // @connect         github.com