// ==UserScript==
// @name totop
// @namespace http://unamerrr.net/
// @version 0.1
// @match *://*/*
// @description 返回顶部
// @author unamerrr
// @grant none
// ==/UserScript==
(function() {
'use strict';
var toTopBtn = document.createElement('button')
toTopBtn.innerHTML = "返回顶部"
toTopBtn.className = "a-b-c-d-toTop"
toTopBtn.onclick = function (e) {
scrollTo(0, 0)
}
var body = document.body
var style = document.createElement('style')
style.id = "a-b-c-d-style"
var css = `.a-b-c-d-toTop{
position: fixed;
bottom: 10%;
right: 5%;
width: 50px;
height: 50px;
border-radius: 50%;
font-size: 15px;
z-index: 999;
cursor: pointer;
font-size: 12px;
overflow: hidden;
}`
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
body.appendChild(toTopBtn)
body.appendChild(style)
// Your code here...
})();
油猴test,在每个页面都添加返回顶部按钮
最新推荐文章于 2024-07-02 23:00:59 发布