Greasy Fork 还支持 简体中文。

Double W and Double S Key Page Scroll

将 'ww' 映射为 Page Up 和 'ss' 映射为 Page Down

  1. // ==UserScript==
  2. // @name Double W and Double S Key Page Scroll
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 将 'ww' 映射为 Page Up 和 'ss' 映射为 Page Down
  6. // @author yueli
  7. // @match *://*/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let wCount = 0;
  16. let sCount = 0;
  17. const resetTime = 500; // 毫秒
  18.  
  19. document.addEventListener('keydown', function(event) {
  20. if (event.key === 'w') {
  21. wCount++;
  22. sCount = 0;
  23. setTimeout(() => wCount = 0, resetTime);
  24. if (wCount === 2) {
  25. window.scrollBy(0, -window.innerHeight);
  26. wCount = 0;
  27. }
  28. } else if (event.key === 's') {
  29. sCount++;
  30. wCount = 0;
  31. setTimeout(() => sCount = 0, resetTime);
  32. if (sCount === 2) {
  33. window.scrollBy(0, window.innerHeight);
  34. sCount = 0;
  35. }
  36. }
  37. });
  38. })();