安乐传 - - 一键 到顶、到底 电脑端、移动端 通用
目前為
// ==UserScript==
// @name 安乐传
// @author Jones Miller
// @version 21.3.17
// @namespace https://t.me/jsday
// @description 安乐传 - - 一键 到顶、到底 电脑端、移动端 通用
// @include *
// @grant unsafeWindow
// ==/UserScript==
(function() {
'use strict';
function s(i){window.scrollTo(0,i)}
var jmfortop = document.createElement("div");
jmfortop = document.body.appendChild(jmfortop);
jmfortop.innerHTML ='<head> <style type="text/css"> .jmfortop { display:none; width:49px; height:88px; background:transparent !important; position:fixed; bottom:30px; right:30px; z-index:100000; border-radius:10px; } .jm_topbtn { position:absolute; width:100%; height:49%; background:rgba(0,0,0,0.5) url(https://g.csdnimg.cn/side-toolbar/2.9/images/fanhuidingbucopy.png) no-repeat center top 50% !important; background-size:20px 20px !important; border-radius:10px; } #jmgo_top:hover,#jmgo_btn:hover { background-color:red !important; } </style> </head> <body> <div id="jmgotop" class="jmfortop"> <div id="jmgo_top" class="jm_topbtn" style="top:0;"></div> <div id="jmgo_btn" class="jm_topbtn" style="bottom:0;transform:rotate(180deg);"></div> </div> </body>'
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 149 || document.documentElement.scrollTop > 149 ) {
document.getElementById("jmgotop").style.display = "block";
} else {
document.getElementById("jmgotop").style.display = "none";
}
}
document.getElementById('jmgo_top').onclick = ()=>{s(0)};
document.getElementById('jmgo_btn').onclick = ()=>{s(document.body.scrollHeight)};
})();