頁首頁尾捲動快捷鍵(L改)

(L改)頁首頁尾、頁面捲動scroll、半頁下跳快捷鍵、看漫畫往下跳頁面;pageup,pagedown代替

当前为 2023-01-11 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @license MIT
// @name		        頁首頁尾捲動快捷鍵(L改)
// @author		        L改
// @description	        (L改)頁首頁尾、頁面捲動scroll、半頁下跳快捷鍵、看漫畫往下跳頁面;pageup,pagedown代替
// @description-EN	        Jump to Top/Bottom of page with hotkeys
// @namespace          	https://greasyfork.org/scripts/440323
// @version				1.3
// @include     	*
// @exclude     	https://mail.google.com/*
// @exclude     	http://dzh.mop.com/*
// @exclude     	http://www.douban.com/photos/*
// @grant			none
// ==/UserScript==

/* ************************ 頁面效果 ************************ */
//top按鈕已去除
//哆啦B梦的弟弟https://greasyfork.org/scripts/794
//翻頁快捷键
(function () {
    var newHeight = document.body.scrollHeight + 9999999999;
    var scroll = {

	//'k' : function() { scrollBy(0,  400) }, // 往下翻400px

	'd' : function() { scrollBy(0,  window.innerHeight / 2) },
        'D' : function() { scrollBy(0,  window.innerHeight / 2) },
	'c' : function() { scrollBy(0,  window.innerHeight / 2) },
        'C' : function() { scrollBy(0,  window.innerHeight / 2) },
	'3' : function() { scrollBy(0,  window.innerHeight / 2) },  // 往下半

	'a' : function() { scrollBy(0, -window.innerHeight / 2) },
        'A' : function() { scrollBy(0, -window.innerHeight / 2) },
	'z' : function() { scrollBy(0, -window.innerHeight / 2) },
        'Z' : function() { scrollBy(0, -window.innerHeight / 2) },
	'1' : function() { scrollBy(0, -window.innerHeight / 2) },  // 往上半

	'f' : function() { scrollBy(0, -window.innerHeight-1) },// 往下頁
        'F' : function() { scrollBy(0, -window.innerHeight-1) },// 往下頁

	'g' : function() { scrollBy(0, window.innerHeight+1) },// 往上頁
	'G' : function() { scrollBy(0, window.innerHeight+1) },// 往上頁

	'w' : function() { scrollTo(0, 0) },
	'W' : function() { scrollTo(0, 0) },// 回頁首

	's' : function() { scrollTo(0,document.body.scrollHeight) },
	'S' : function() { scrollTo(0,document.body.scrollHeight) },// 回頁尾
    };
    var formElement = { 'input':true, 'button':true, 'select':true, 'textarea':true };
    window.addEventListener('keypress',
        function(e) {
            if (e.metaKey || e.ctrlKey || e.altKey ||
                formElement[e.target.tagName.toLowerCase()] || e.target.isContentEditable || document.designMode ==="on") {
                return; }
            var key = (e.shiftKey? 'S-' : '') + String.fromCharCode(e.charCode);
            if (scroll[key]) {
                scroll[key]();
                e.preventDefault();
                e.stopPropagation();
            }
        }, false);
})();