YouTube ShortsKeys

Adds ArrowRight and ArrowLeft keys to YouTube Shorts same as ArrowUp and ArrowDown!

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         YouTube ShortsKeys
// @namespace    YouTubeShortsKeys
// @version      2.0.1
// @description  Adds ArrowRight and ArrowLeft keys to YouTube Shorts same as ArrowUp and ArrowDown!
// @author       Runterya
// @homepage     https://github.com/Runteryaa
// @match        *://*.youtube.com/shorts/*
// @match        *://*.youtube-nocookie.com/shorts/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license      MIT
// @compatible   chrome
// @compatible   edge
// @compatible   firefox
// @compatible   opera
// @compatible   safari
// ==/UserScript==

console.log("YouTube ShortsKeys");

document.addEventListener('keydown', function(event) {
    console.log("Keydown event detected:", event.key);
    if (event.key === 'ArrowRight') {
        console.log("Right arrow key pressed. UP!");

        const upArrowEvent = new KeyboardEvent('keydown', {
            key: 'ArrowUp',
            code: 'ArrowUp',
            keyCode: 38,
            which: 38,
            bubbles: true,
            cancelable: true,
            composed: true
        });

        console.log("Simulating up arrow key press.");
        document.dispatchEvent(upArrowEvent);

        console.log("Up arrow key event dispatched.");
    }
});

document.addEventListener('keydown', function(event) {
    console.log("Keydown event detected:", event.key);
    if (event.key === 'ArrowLeft') {
        console.log("Left arrow key pressed. DOWN!");

        const downArrowEvent = new KeyboardEvent('keydown', {
            key: 'ArrowDown',
            code: 'ArrowDown',
            keyCode: 40,
            which: 40,
            bubbles: true,
            cancelable: true,
            composed: true
        });

        console.log("Simulating down arrow key press.");
        document.dispatchEvent(downArrowEvent);

        console.log("Down arrow key event dispatched.");
    }
});

document.addEventListener('keydown', function(event) {
    console.log("Captured event:", event.key);
});