// ==UserScript== // @name 上下滚动按钮 // @namespace Violentmonkey Scripts // @match *://*/* // @grant none // @version 1.0.0.4 // @author 人民的勤务员 & d3ward // @description Script to scrollBy to top/bottom // @supportURL https://github.com/ChinaGodMan/UserScripts/issues // @homepageURL https://github.com/ChinaGodMan/UserScripts // @downloadURL none // ==/UserScript== //Variable to set how much to scroll var sH = (window.innerHeight) - 50 //top button var topBtn = document.createElement('span') topBtn.innerHTML = '' topBtn.style.cssText = 'text-align:center;background:#191919;border-radius:8px;color:#000000;cursor:pointer;position:fixed;bottom:50%;width:36px;height:36px;right:10px;z-index:9999' topBtn.addEventListener('click', function () { window.scrollBy({ top: -sH, behavior: 'smooth' }) }, false) document.body.appendChild(topBtn) //bottom button var bottomBtn = document.createElement('span') bottomBtn.innerHTML = '' bottomBtn.style.cssText = 'text-align:center;background:#191919;border-radius:8px;color:#000000;cursor:pointer;position:fixed;bottom:45%;width:36px;height:36px;right:10px;z-index:9999'//top:52%; bottomBtn.addEventListener('click', function () { window.scrollBy({ top: sH, behavior: 'smooth' }) }, false) document.body.appendChild(bottomBtn)