安乐传

一键到顶、到底; 电脑端、移动端通用。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         安乐传
// @author       Jones Miller
// @version      23.04.01
// @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 { position:fixed; display:block; width:49px; height:88px; bottom:30px; right:-60px; background:transparent !important; z-index:100000; transition:.5s 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;} #jmchuan div:hover { background-color:red !important; background-size:26px !important;} </style> </head> <body> <div id="jmchuan"> <div id="jmgotop" style="top:0;"></div> <div id="jmgobtn" 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.right='-60px';
    }
  }
  jmgotop.onclick=()=>{
    s(0);
  };
  jmgobtn.onclick=()=>{
    s(document.body.scrollHeight);
  };

})();