PCR作业网返回顶部按钮

给PCR作业网增加“返回顶部”按钮

// ==UserScript==
// @name        PCR作业网返回顶部按钮
// @namespace   Violentmonkey Scripts
// @match       *://*pcrdfans*/*
// @grant       none
// @version     1.0
// @author      千城忆梦
// @description 给PCR作业网增加“返回顶部”按钮
// @description 非原创,修改自https://blog.csdn.net/insgo/article/details/113799700,感谢原作者!
// ==/UserScript==

(function() {
    'use strict';
    var toTopBtn = document.createElement('button')
    toTopBtn.innerHTML = "UP"
    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)
})();