Scroll Up

Tool to let you scroll to the top of the page

目前為 2017-08-30 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Scroll Up
  3. // @version 1.01
  4. // @description Tool to let you scroll to the top of the page
  5. // @author A Meaty Alt
  6. // @exclude https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=21
  7. // @include /fairview.deadfrontier.com/
  8. // @exclude https://fairview.deadfrontier.com/onlinezombiemmo/ExternalLoginReg.php
  9. // @exclude http://chat.deadfrontier.com
  10. // @grant none
  11. // @namespace
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. var scroller = document.createElement("img");
  17. scroller.src = "https://puu.sh/xluRH/c8dd354a59.png";
  18. scroller.id = "scroller";
  19. scroller.style.opacity = 0.3;
  20. scroller.style.position = "fixed";
  21. scroller.style.zIndex = 99;
  22. scroller.style.cursor = "pointer";
  23. scroller.style.bottom = "30px";
  24. scroller.style.right = "20px";
  25. scroller.height = 100;
  26. scroller.width = 100;
  27. function defineOnClickEvent(){
  28. $(scroller).click(function() {
  29. $("html, body").animate({ scrollTop: 0 }, "slow");
  30. return false;
  31. });
  32. }
  33. function defineOnScrollEvent(){
  34. $(document).scroll(function() {
  35. if($(window).scrollTop() === 0) {
  36. $("#scroller").css("opacity", 0.3);
  37. }
  38. else
  39. $("#scroller").css("opacity", 1);
  40. });
  41. }
  42. defineOnScrollEvent();
  43. defineOnClickEvent();
  44. document.getElementsByTagName("body")[0].appendChild(scroller);
  45. })();