mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-15 07:57:09 +03:00
Fix next chapter hotkey causing multiple chapters to be skipped on Chrome
Fixes #2276
This commit is contained in:
@@ -2617,25 +2617,13 @@ async function handleKeybindVote(type: number): Promise<void>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addHotkeyListener(): void {
|
function addHotkeyListener(): void {
|
||||||
document.addEventListener("keydown", hotkeyListener);
|
document.addEventListener("keydown", hotkeyListener, true);
|
||||||
|
document.addEventListener("keyup", hotkeyPropagationListener, true);
|
||||||
const onLoad = () => {
|
|
||||||
// Allow us to stop propagation to YouTube by being deeper
|
|
||||||
document.removeEventListener("keydown", hotkeyListener);
|
|
||||||
document.body.addEventListener("keydown", hotkeyListener);
|
|
||||||
document.body.addEventListener("keyup", hotkeyPropagationListener);
|
|
||||||
|
|
||||||
addCleanupListener(() => {
|
addCleanupListener(() => {
|
||||||
document.body.removeEventListener("keydown", hotkeyListener);
|
document.body.removeEventListener("keydown", hotkeyListener, true);
|
||||||
document.body.removeEventListener("keyup", hotkeyPropagationListener);
|
document.body.removeEventListener("keyup", hotkeyPropagationListener, true);
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
if (document.readyState === "complete") {
|
|
||||||
onLoad();
|
|
||||||
} else {
|
|
||||||
document.addEventListener("DOMContentLoaded", onLoad);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hotkeyListener(e: KeyboardEvent): void {
|
function hotkeyListener(e: KeyboardEvent): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user