安乐传 - - 一键 到顶、到底 电脑端、移动端 通用
当前为
// ==UserScript==
// @name 安乐传
// @author Jones Miller
// @version 21.5.25
// @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"> #jmchuan { display:block;width:49px;height:88px;background:transparent !important;position:fixed;bottom:30px;right:-55px;z-index:100000;transition:1s all;border-radius:10px;} #jmchuan div { 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 !important;background-size:18px !important;border-radius:10px;} #jmchuango_top:hover,#jmchuango_btn:hover { background-color:red !important;} </style> </head> <body> <div id="jmchuan"><div id="jmchuango_top" style="top:0;"></div><div id="jmchuango_btn" style="bottom:0;transform:rotate(180deg);"></div></div> </body>'
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 149 || document.documentElement.scrollTop > 149 ) {
jmchuan.style='right:10px;';
} else {
jmchuan.style='';
}
}
jmchuango_top.onclick=()=>{s(0)};
jmchuango_btn.onclick=()=>{s(document.body.scrollHeight)};
})();