// ==UserScript==
// @license MIT
// @name 頁首頁尾捲動快捷鍵(L改)
// @author 哆啦B梦的弟弟https://greasyfork.org/scripts/794
// @description Jump to Top/Bottom of page with hotkeys(L改)頁首頁尾、頁面捲動scroll、半頁下跳快捷鍵、看漫畫往下跳頁面
// @namespace https://greasyfork.org/scripts/440323
// @version 1.2
// @include *
// @exclude https://mail.google.com/*
// @exclude http://dzh.mop.com/*
// @exclude http://www.douban.com/photos/*
// @grant none
// ==/UserScript==
/* ************************ 頁面效果 ************************ */
//top按鈕
//翻頁快捷键
(function () {
var newHeight = document.body.scrollHeight + 9999999999;
var scroll = {
// 'v' : function() { scrollBy(0, -(window.innerHeight+1)/2) },
// 'b' : function() { scrollBy(0, (window.innerHeight+1)/2) }, // 往下翻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);
})();