Greasy Fork 支持简体中文。

Holodex - Auto Click Sort Dropdown and Select Most Viewers (With Load Detection)

Automatically clicks the sort dropdown and selects "Most Viewers" on Holodex.net with load detection

  1. // ==UserScript==
  2. // @name Holodex - Auto Click Sort Dropdown and Select Most Viewers (With Load Detection)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description Automatically clicks the sort dropdown and selects "Most Viewers" on Holodex.net with load detection
  6. // @author ChatGPT
  7. // @match https://holodex.net/*
  8. // @grant none
  9. // @run-at document-idle
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. // 정렬 아이콘 클릭을 위한 함수
  16. function findSortButton() {
  17. return [...document.querySelectorAll('svg.v-icon__svg')].find(svg => {
  18. const path = svg.querySelector('path');
  19. return path?.getAttribute('d') === 'M6,13H18V11H6M3,6V8H21V6M10,18H14V16H10V18Z';
  20. })?.closest('button');
  21. }
  22.  
  23. // "Sort" 탭 클릭
  24. function clickSortTab() {
  25. const sortTab = document.querySelector('.v-select__selection--comma');
  26. if (sortTab && sortTab.textContent.includes('Latest')) {
  27. console.log('[Tampermonkey] "Sort" tab found, clicking...');
  28. sortTab.click();
  29. } else {
  30. console.log('[Tampermonkey] "Sort" tab not found!');
  31. }
  32. }
  33.  
  34. // "Most Viewers" 항목 선택
  35. function selectMostViewers() {
  36. const listItems = document.querySelectorAll('.v-list-item');
  37. for (const item of listItems) {
  38. if (item.textContent.includes('Most Viewers')) {
  39. console.log('[Tampermonkey] "Most Viewers" found, selecting...');
  40. item.click();
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46.  
  47. // 첫 번째 정렬 버튼 클릭 및 이후 단계 처리
  48. function trySortClickAndSelect() {
  49. const sortButton = findSortButton();
  50. if (sortButton) {
  51. console.log('[Tampermonkey] Sort button found, clicking...');
  52. sortButton.click();
  53.  
  54. // 바로 "Sort" 탭 클릭
  55. clickSortTab();
  56.  
  57. // "Most Viewers" 항목을 바로 선택 시도
  58. if (!selectMostViewers()) {
  59. console.log('[Tampermonkey] "Most Viewers" not found yet, retrying...');
  60. // 만약 아직 항목이 준비되지 않았다면 다시 시도
  61. setTimeout(() => {
  62. console.log('[Tampermonkey] Retry select "Most Viewers"...');
  63. selectMostViewers();
  64. }, 300);
  65. }
  66. } else {
  67. console.log('[Tampermonkey] Sort button not found!');
  68. }
  69. }
  70.  
  71. // 로딩 완료 감지 함수
  72. function detectPageLoad() {
  73. // 페이지 로딩이 완료되고 나면 클릭 작업 시작
  74. if (document.readyState === 'complete') {
  75. console.log('[Tampermonkey] Page loaded, starting sort click...');
  76. trySortClickAndSelect();
  77. }
  78. }
  79.  
  80. // 페이지 로딩 상태 감지
  81. window.addEventListener('load', detectPageLoad);
  82.  
  83. // DOM 변화 감지
  84. const observer = new MutationObserver(() => {
  85. const sortButton = findSortButton();
  86. if (sortButton) {
  87. sortButton.click();
  88. console.log('[Tampermonkey] Sort dropdown button clicked');
  89. observer.disconnect(); // 버튼 클릭 후 감지 종료
  90.  
  91. // 버튼 클릭 후 나머지 작업 수행
  92. trySortClickAndSelect();
  93. }
  94. });
  95.  
  96. // 페이지 로드 후 감지 시작
  97. window.addEventListener('load', () => {
  98. console.log('[Tampermonkey] Script loaded, starting observer...');
  99. observer.observe(document.body, { childList: true, subtree: true });
  100. });
  101. })();