// ==UserScript== // @name 脚本猫脚本站美化 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.2 // @description 脚本猫脚本站个性美化,向下滚动会出现返回顶部按钮! // @author 张仨 // @match https://scriptcat.org/* // @run-at document-start // @grant GM_addStyle // @grant unsafeWindow // ==/UserScript== GM_addStyle(` /*背景*/ body{ background-image: url(https://tva3.sinaimg.cn/large/0076R7yAgy1fq8ds6c448j31hc0u016f.jpg) !important; background-repeat: no-repeat; background-position: top; background-attachment: fixed; } /*导航栏*/ .q-header, .q-toolbar{ background: rgba(0,0,0,0) !important; height: 45px !important; } /*底部导航*/ .q-footer{ display: none !important; } /*LOGO*/ .logo-title{ color: #d0e2f6 !important; } /*字体*/ .text-black { color: #2e6ad8 !important; } /*标题*/ .text-h4{ color: #477bc4 !important; } .q-card, .show-mess-page{ background: rgba(255,255,255,0.6) !important; margin-top: 10px !important; padding: 0px 15px !important; border-radius: 7px !important; } .show-mess-page, .justify-end{ background: rgba(0,0,0,0) !important; } .top_1{ position: fixed; display: none; bottom: 60px; right: 80px; width: 45px; height: 45px; cursor: pointer; border-radius: 100%; background: #ffffff; } .top_1 img{ position: absolute; margin: 10px 10px; width: 25px; height: 25px; } .top_1 span{ position: absolute; display: none; margin: 6px 10px; font-size: 6px; border-radius: 100%; background: #ffffff; } .top_1:hover span{ display: block; } /*平滑滚动*/ html{ scroll-behavior: smooth; } `) unsafeWindow.onload = function () { 'use strict'; //返回顶部按钮 var div = document.createElement("div"); document.body.appendChild(div); div.innerHTML = `
返回
顶部
` var top = document.querySelector(".top_1"); window.onscroll = () => { var t = document.documentElement.scrollTop || document.body.scrollTop; if (t >= 800) { top.style.display = "block"; } else { top.style.display = "none"; } } div.onclick = () => { window.scrollTo(0, 0); } }