// ==UserScript==
// @name [zrh] 回到顶部、前往底部
// @namespace http://tampermonkey.net/
// @version 1.2
// @description 显示 回到顶部、前往底部 按钮
// @author zrh
// @match *://*/*
// @icon https://cdn3.iconfinder.com/data/icons/leto-space/64/__rocket_spaceship-64.png
// @noframes
// @license MIT
// @grant none
// @downloadURL https://update.greasyfork.icu/scripts/460553/%5Bzrh%5D%20%E5%9B%9E%E5%88%B0%E9%A1%B6%E9%83%A8%E3%80%81%E5%89%8D%E5%BE%80%E5%BA%95%E9%83%A8.user.js
// @updateURL https://update.greasyfork.icu/scripts/460553/%5Bzrh%5D%20%E5%9B%9E%E5%88%B0%E9%A1%B6%E9%83%A8%E3%80%81%E5%89%8D%E5%BE%80%E5%BA%95%E9%83%A8.meta.js
// ==/UserScript==
(function() {
'use strict';
if (document.readyState === "complete" || (document.readyState !== "loading" && !document.documentElement.doScroll)) {
setTimeout(() => main_(), 1000);
} else {
document.addEventListener("DOMContentLoaded", function () { setTimeout(() => main_(), 1000) });
}
function main_(){
createButtonToTop()
createButtonToBottom()
}
function createButtonToTop() {
const btn = document.createElement('div')
btn.innerHTML = '
'
var img = btn.firstChild;
img.style.opacity = 0.2
img.addEventListener('mouseover', function(){ img.style.opacity = 1;}, false);
img.addEventListener('mouseout', function(){ img.style.opacity = 0.2; }, false);
btn.style.fontSize = '28px'
btn.style.fontWeight = 900
btn.style.textAlign = 'center'
btn.style.lineHeight = '50px'
btn.style.cursor = 'pointer'
btn.style.width = '50px'
btn.style.height = '50px'
btn.style.background = 'transparent'
btn.style.position = 'fixed'
btn.style.right = '50px'
btn.style.bottom = '55px'
btn.onclick = () => scrollTo(0, 0)
btn.oncontextmenu = (e) => {
e.preventDefault()
btn.style.display = 'none'
}
document.querySelector('html body').appendChild(btn)
}
function createButtonToBottom() {
const btn = document.createElement('div')
btn.innerHTML = '
'
var img = btn.firstChild;
img.style.opacity = 0.2
img.addEventListener('mouseover', function(){ img.style.opacity = 1;}, false);
img.addEventListener('mouseout', function(){ img.style.opacity = 0.2; }, false);
btn.style.fontSize = '28px'
btn.style.fontWeight = 900
btn.style.textAlign = 'center'
btn.style.lineHeight = '50px'
btn.style.cursor = 'pointer'
btn.style.width = '50px'
btn.style.height = '50px'
btn.style.background = 'transparent'
btn.style.position = 'fixed'
btn.style.right = '50px'
btn.style.bottom = '5px'
btn.onclick = () => scrollTo(0, 9999999999)
btn.oncontextmenu = (e) => {
e.preventDefault()
btn.style.display = 'none'
}
document.querySelector('html body').appendChild(btn)
}
})();