Space Bar Scroll Half Page

try to take over the world!

目前為 2020-12-20 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Space Bar Scroll Half Page
// @namespace    https://github.com/chenshengzhi
// @version      0.0.1
// @description  try to take over the world!
// @author       You
// @match        https://*/*
// @match        http://*/*
// @grant        none
// ==/UserScript==

function SBSHP_KeyCheck(key){
  // Don't modify text editing
  if (key.target.nodeName == "INPUT" || key.target.nodeName == "TEXTAREA" || key.target.nodeName == "SELECT") return;
  if (key.target.hasAttribute("contenteditable") && key.target.getAttribute("contenteditable") == "true") return;
  // Don't modify certain combinations
  if (key.ctrlKey || key.altKey || key.metaKey) return;
  // If it's a space character, kill the event
  if (key.key == ' '){
    key.stopPropagation();
    key.preventDefault();
    window.content.scrollBy({
        top: window.content.innerHeight / 2,
        left: 0,
        behavior: "smooth"
    });
    return false;
  }
}
// Monitor the keydown event
document.addEventListener('keydown', SBSHP_KeyCheck);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址