Next chapter in mangalib.me automatically

Click next chapter in mangalib.me automatically

当前为 2023-10-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Next chapter in mangalib.me automatically
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Click next chapter in mangalib.me automatically
  6. // @author Killua Kill
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=mangalib.me
  8. // @match https://ranobelib.me/*
  9. // @match https://mangalib.me/*
  10. // @license MIT
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Function to check if the button is visible on the screen
  18. function isButtonVisible() {
  19. var button = document.querySelectorAll('.reader-next__btn')[1];
  20. var rect = button.getBoundingClientRect();
  21. return (
  22. rect.top >= 0 &&
  23. rect.left >= 0 &&
  24. rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
  25. rect.right <= (window.innerWidth || document.documentElement.clientWidth)
  26. );
  27. }
  28.  
  29. // Function to click the button
  30. function clickButton() {
  31. var button = document.querySelectorAll('.reader-next__btn')[1];
  32. button.click();
  33. }
  34.  
  35. // Check if the button is visible on the screen and click it
  36. if (isButtonVisible()) {
  37. clickButton();
  38. } else {
  39. // If the button is not visible, wait for it to appear and then click it
  40. var observer = new MutationObserver(function(mutationsList) {
  41. for (var mutation of mutationsList) {
  42. if (mutation.type === 'childList' && isButtonVisible()) {
  43. clickButton();
  44. observer.disconnect();
  45. break;
  46. }
  47. }
  48. });
  49.  
  50. observer.observe(document.body, { childList: true, subtree: true });
  51. }
  52. })();