安乐传

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

  1. // ==UserScript==
  2. // @name 安乐传
  3. // @author Jones Miller
  4. // @version 23.04.01
  5. // @namespace https://t.me/jsday
  6. // @description 一键到顶、到底; 电脑端、移动端通用。
  7. // @include *
  8. // @grant unsafeWindow
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function s(i){ window.scrollTo(0,i);};
  15. var jmfortop=document.createElement("div");
  16. jmfortop=document.body.appendChild(jmfortop);
  17. 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>';
  18. window.onscroll=function() { scrollFunction();};
  19. function scrollFunction() {
  20. if (document.body.scrollTop > 149 || document.documentElement.scrollTop > 149 ) {
  21. jmchuan.style.right='10px';
  22. } else {
  23. jmchuan.style.right='-60px';
  24. }
  25. }
  26. jmgotop.onclick=()=>{
  27. s(0);
  28. };
  29. jmgobtn.onclick=()=>{
  30. s(document.body.scrollHeight);
  31. };
  32.  
  33. })();