AutoClickPagerize

just click more-load or next-page button

  1. // ==UserScript==
  2. // @name AutoClickPagerize
  3. // @version 1
  4. // @namespace http://xxyyzz.net/
  5. // @description just click more-load or next-page button
  6. // @author kuma
  7. // @match http://*/*
  8. // @match https://*/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function(){
  13. var SITEINFO=[
  14. {
  15. url:'^https?://jp\\.reuters\\.com/',
  16. nextElement:'//div[@class="more-load"]',
  17. exampleURL:'https://jp.reuters.com/theWire'
  18. },
  19. {
  20. url:'^https?://www3\\.nhk\\.or\\.jp/',
  21. nextElement:'//footer[@class="module--footer button-more"]/p',
  22. exampleURL:'https://www3.nhk.or.jp/news/catnew.html'
  23. },
  24. {
  25. url:'^https?://www\\.afpbb\\.com/',
  26. nextElement:'id("next-pager-latest")[not(@style="display: none;")]',
  27. exampleURL:'http://www.afpbb.com/list/latest'
  28. },
  29. {
  30. url:'^https?://dot\\.asahi\\.com/',
  31. nextElement:'id("js_foldedBtnReadmore")',
  32. exampleURL:'https://dot.asahi.com/dot/2018102400082.html'
  33. },
  34. {
  35. url:'^https?://duckduckgo\\.com/\\?q=',
  36. nextElement:'//a[@class="result--more__btn btn btn--full"]',
  37. exampleURL:'https://duckduckgo.com/?q=monkey&t=ffsb&ia=web'
  38. }
  39. ];
  40. function getInfo(){
  41. for (const info of SITEINFO) {
  42. if((new RegExp(info.url)).exec(document.URL))return info;
  43. }
  44. return false;
  45. }
  46. function getElementByXpath(path) {
  47. return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  48. }
  49. var info=getInfo();
  50. if(!info)return;
  51. console.log("--- debug ---");
  52. var clickonce=true;
  53. var scroll= function() {
  54. var nextel=getElementByXpath(info.nextElement);
  55. if(!nextel)return;
  56. if(nextel.getBoundingClientRect().top-window.innerHeight+nextel.offsetHeight>-50)return;
  57. if(!clickonce)return;
  58. clickonce=false;
  59. nextel.click();
  60. setTimeout(function(){clickonce=true;}, 1000);
  61. }
  62. window.addEventListener("scroll", scroll, false);
  63. scroll();
  64. })();