Greasy Fork 支持简体中文。

Optimize Browser

Have a better experience to use browser.

  1. // ==UserScript==
  2. // @name Optimize Browser
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1.0
  5. // @description Have a better experience to use browser.
  6. // @author Eugene Liu
  7. // @match *://*/*
  8. // ==/UserScript==
  9.  
  10. (function () {//Ignore MouseWheel,only care key and mouse.
  11. var timerID;
  12. var timeout;
  13. var speed = 50;
  14. var EugeneScroll;
  15. var stopAutoScroll = false;
  16.  
  17. document.onkeydown = function (event) {
  18. var e = event || window.event || arguments.callee.caller.arguments[0];
  19. if (e && e.keyCode == 118) {
  20. if (stopAutoScroll === false) {
  21. stopAutoScroll = true;
  22. } else {
  23. stopAutoScroll = false;
  24. }
  25. }
  26. };
  27.  
  28. function ScreenSaver(settings) {
  29. timeout = settings.timeout;
  30. document.body.onmousemove = document.body.onmousedown = document.body.onkeydown = document.body.onkeypress = ScreenSaver.prototype.onevent;
  31. timerID = window.setTimeout(function () {
  32. if (!stopAutoScroll) {
  33. moveDown();
  34. }
  35. }, timeout);
  36. }
  37.  
  38. ScreenSaver.prototype.onevent = function (e) {
  39. window.clearTimeout(timerID);
  40. stopMove();
  41. timerID = window.setTimeout(function () {
  42. if (!stopAutoScroll) {
  43. moveDown();
  44. }
  45. }, timeout);
  46. };
  47.  
  48. function initScreenSaver() {
  49. new ScreenSaver({timeout: 5000});
  50. }
  51.  
  52. function moveDown() {
  53. EugeneScroll = setInterval(function () {
  54. window.scrollBy(0, +1);
  55. }, speed);
  56. }
  57.  
  58. function stopMove() {
  59. clearInterval(EugeneScroll);
  60. }
  61.  
  62. window.onload = function () {
  63. initScreenSaver();
  64. }
  65. })();