您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add semi-transparent PageUp/PageDown buttons to the right of every page. Useful when reading web pages on e-ink screens.
当前为
// ==UserScript== // @name PageUp/PageDown buttons // @namespace http://tampermonkey.net/ // @version 0.1 // @description Add semi-transparent PageUp/PageDown buttons to the right of every page. Useful when reading web pages on e-ink screens. // @author xiaq // @match *://*/* // @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net // @grant none // @license BSD 2-clause // ==/UserScript== (function() { 'use strict'; const container = document.createElement('div'); setStyle(container, { position: 'fixed', right: '8px', top: 'calc(50% - 48px)', display: 'flex', 'flex-direction': 'column', opacity: '0.5', }) const buttonStyle = { width: '48px', height: '48px', 'font-size': '32px', border: '1px solid black', display: 'flex', 'align-items': 'center', 'justify-content': 'center', }; const scrollFactor = 0.8; const pageUp = document.createElement('button'); pageUp.innerText = '▲'; setStyle(pageUp, buttonStyle); pageUp.onclick = () => { window.scrollBy(0, -scrollFactor * window.innerHeight) }; const pageDown = document.createElement('button'); pageDown.innerText = '▼'; setStyle(pageDown, buttonStyle); pageDown.onclick = () => { window.scrollBy(0, scrollFactor * window.innerHeight) }; container.appendChild(pageUp); container.appendChild(pageDown); document.body.appendChild(container); function setStyle(elem, obj) { elem.style = Object.entries(obj).map(([k, v]) => k+':'+v).join(';'); } })();