Youtube: UpDown to Scroll

Bind the spacebar to play/pause the video.

目前為 2017-03-21 提交的版本,檢視 最新版本

// ==UserScript==
// @name            Youtube: UpDown to Scroll
// @description     Bind the spacebar to play/pause the video.
// @author          Chris H (Zren)
// @icon            https://youtube.com/favicon.ico
// @namespace       http://xshade.ca
// @version         1
// @include         http*://*.youtube.com/*
// @include         http*://youtube.com/*
// @include         http*://*.youtu.be/*
// @include         http*://youtu.be/*
// ==/UserScript==

window.addEventListener('keydown', function(e) {
    var validTarget = e.target === document.querySelector('#movie_player') || e.target === document.querySelector('#player-api');
    if (validTarget) {
        if (e.keyCode === 38) { // ArrowUp
            e.stopPropagation()
        } else if (e.keyCode === 40) { // ArrowDown
            e.stopPropagation()
        }
    }
}, true);