動畫瘋 自動展開「留言板」之前留言

當滾動到頁面底部時,自動點擊展開之前留言按鈕。

  1. // ==UserScript==
  2. // @name 動畫瘋 自動展開「留言板」之前留言
  3. // @version 1.2
  4. // @description 當滾動到頁面底部時,自動點擊展開之前留言按鈕。
  5. // @author movwei
  6. // @license MIT
  7. // @match https://ani.gamer.com.tw/animeVideo.php?sn=*
  8. // @namespace https://gf.qytechs.cn/users/1041101
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. let expanding = false;
  15.  
  16. function simulateClick(element) {
  17. if (element) {
  18. var event = new Event('click', {
  19. bubbles: true,
  20. cancelable: true
  21. });
  22. element.dispatchEvent(event);
  23. }
  24. }
  25.  
  26. function isPageBottom() {
  27. return (window.innerHeight + window.scrollY) >= document.body.offsetHeight - 2;
  28. }
  29.  
  30. function checkAndClick() {
  31. if (isPageBottom() && !expanding) {
  32. var expandButton = document.querySelector('.c-msg-item.c-more-msg[data-evt-morecomment]');
  33. if (expandButton) {
  34. expanding = true;
  35. simulateClick(expandButton);
  36. console.log('已點擊展開按鈕');
  37.  
  38. // 使用 MutationObserver 監控內容變化
  39. var observer = new MutationObserver(() => {
  40. expanding = false;
  41. });
  42. observer.observe(document.body, { childList: true, subtree: true });
  43. } else {
  44. console.log('未找到展開按鈕');
  45. }
  46. }
  47. }
  48.  
  49. window.addEventListener('scroll', checkAndClick);
  50.  
  51. })();

QingJ © 2025

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