Greasy Fork镜像 支持简体中文。

NewsFan.jp 自動翻頁和點擊

自動滾動並點擊「続きを読む」,若找不到則點擊「スタンプページへ」連結

  1. // ==UserScript==
  2. // @name NewsFan.jp 自動翻頁和點擊
  3. // @namespace https://github.com/lchanc3/userscript
  4. // @version 1.1
  5. // @license MIT
  6. // @description 自動滾動並點擊「続きを読む」,若找不到則點擊「スタンプページへ」連結
  7. // @homepage https://github.com/lchanc3/userscript
  8. // @supportURL https://github.com/lchanc3/userscript/issues
  9. // @author lchanc3
  10. // @match https://www.life-n.jp/sp/article/?article_id=*
  11. // @match https://www.trepy.jp/sp/article/?article_id=*
  12. // @match https://point-news.jp/sp/article/?article_id=*
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. let lastHeight = 0; // 記錄上次滾動的高度
  20. let scrollInterval = 50; // 滾動頻率
  21. let buttonCheckInterval = 150; // 檢查是否有按鈕頻率
  22. let maxScrollAttempts = 10; // 最大嘗試滾動次數
  23.  
  24. // 自動滾動到底部
  25. function autoScroll() {
  26. let attempts = 0;
  27.  
  28. let scrollLoop = setInterval(() => {
  29. window.scrollTo(0, document.body.scrollHeight);
  30.  
  31. if (document.body.scrollHeight === lastHeight) {
  32. attempts++;
  33. if (attempts >= maxScrollAttempts) {
  34. console.log("已經無法再滾動,停止滾動");
  35. clearInterval(scrollLoop);
  36. }
  37. } else {
  38. attempts = 0;
  39. }
  40.  
  41. lastHeight = document.body.scrollHeight;
  42. }, scrollInterval);
  43. }
  44.  
  45. // 自動點擊按鈕(先點擊 `btnNext`,若找不到則點擊 `button_stamp` 內的 `<a>`)
  46. function autoClickButton() {
  47. let clickLoop = setInterval(() => {
  48. let button = document.querySelector('[class^="btnNext"]');
  49.  
  50. if (button) {
  51. console.log("發現按鈕「続きを読む」,正在點擊...", button.className);
  52. button.click();
  53. return;
  54. }
  55.  
  56. let link = document.querySelector('.button_stamp a');
  57. if (link) {
  58. console.log("未找到「続きを読む」,改點擊「スタンプページへ」連結", link.href);
  59. window.location.href = link.href;
  60. } else {
  61. console.log("未找到「続きを読む」與「スタンプページへ」,繼續檢查...");
  62. }
  63. }, buttonCheckInterval);
  64. }
  65.  
  66.  
  67. autoScroll();
  68. autoClickButton();
  69. })();

QingJ © 2025

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