Greasy Fork镜像 支持简体中文。

水木社区 - 自动翻页

水木社区自动翻页,方向左键上一页,方向右键上一页

  1. // ==UserScript==
  2. // @name 水木社区 - 自动翻页
  3. // @version 1.0
  4. // @author Siukei
  5. // @description 水木社区自动翻页,方向左键上一页,方向右键上一页
  6. // @match *://*.newsmth.net/*
  7. // @icon https://static.mysmth.net/nForum/favicon.ico
  8. // @grant GM_xmlhttpRequest
  9. // @grant GM_registerMenuCommand
  10. // @grant GM_unregisterMenuCommand
  11. // @grant GM_openInTab
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_notification
  15. // @license GPL-3.0 License
  16. // @run-at document-end
  17. // @namespace https://www.newsmth.net
  18. // @require https://cdn.jsdelivr.net/npm/jquery@3.5.0/dist/jquery.min.js
  19. // ==/UserScript==
  20.  
  21. (function () {
  22. document.addEventListener('keydown', function (event) {
  23. if (event.key === 'ArrowRight') { // ArrowRight 表示键盘右箭头键的键码
  24. nextPage(true);
  25. }
  26. if (event.key === 'ArrowLeft') { // ArrowLeft 表示键盘右箭头键的键码
  27. nextPage(false);
  28. }
  29. });
  30.  
  31. window.onscroll = function () {
  32. if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
  33. // nextPage(true);
  34. }
  35. };
  36.  
  37. function nextPage(isNext) {
  38. var selector = isNext ? 'last-child' : 'first-child'
  39. var a = document.querySelector(`ul.pagination > li > ol.page-main > li:${selector} > a`);
  40. if (a) {
  41. a.click(); // 触发点击事件
  42. }
  43. }
  44. })();
  45.  
  46.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址