Review Skip

Clicks the "Skip" button every time it appears

目前为 2024-08-03 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Review Skip
  3. // @namespace https://greasyfork.org/en/users/1291009
  4. // @version 2.2
  5. // @description Clicks the "Skip" button every time it appears
  6. // @author BadOrBest
  7. // @license MIT
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=acellus.com
  9. // @match https://admin192c.acellus.com/student/*
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @grant GM_info
  13. // @grant GM_listValues
  14. // @grant GM_deleteValue
  15. // @grant GM_disable
  16. // @grant GM.registerMenuCommand
  17. // @run-at document-end
  18. // ==/UserScript==
  19. (function() {
  20. 'use strict';
  21.  
  22. let isEnabled = false; // Flag to track script enable/disable
  23. let debounceTimer; // Timer for debouncing continuous clicking
  24. let reloadOnDisable = GM_getValue('reloadOnDisable', false); // Get the reload option state
  25.  
  26. // Function to click the "Skip" button
  27. function clickSkipButton(skipElement) {
  28. try {
  29. if (skipElement) {
  30. skipElement.click();
  31. }
  32. } catch (error) {
  33. console.error('Error clicking skip button:', error);
  34. }
  35. }
  36.  
  37. // Function to handle mutations
  38. function handleMutations(mutationsList, observer) {
  39. for (const mutation of mutationsList) {
  40. if (mutation.type === 'childList') {
  41. const newSkipElements = Array.from(mutation.addedNodes).filter(node => node.textContent.trim() === 'Skip');
  42. if (newSkipElements.length > 0) {
  43. if (isEnabled) {
  44. newSkipElements.forEach(newSkipElement => clickSkipButton(newSkipElement));
  45. }
  46. }
  47. }
  48. }
  49. }
  50.  
  51. // Function to continuously click the "Skip" button with debouncing
  52. function clickSkipButtonContinuously() {
  53. clearTimeout(debounceTimer);
  54. debounceTimer = setTimeout(() => {
  55. const skipSpans = Array.from(document.querySelectorAll('span')).filter(span => span.textContent.trim() === 'Skip');
  56. if (isEnabled) {
  57. skipSpans.forEach(span => clickSkipButton(span));
  58. }
  59. }, 500);
  60. }
  61.  
  62. // Create a MutationObserver to watch for changes in the DOM
  63. const observer = new MutationObserver(handleMutations);
  64. observer.observe(document.documentElement, { childList: true, subtree: true });
  65.  
  66. // Function to toggle script enable/disable
  67. function toggleScript() {
  68. isEnabled = !isEnabled;
  69. if (isEnabled) {
  70. toggleButton.textContent = 'Review Skip ON';
  71. toggleButton.classList.remove('script-off');
  72. toggleButton.classList.add('script-on');
  73. toggleButton.style.backgroundColor = '#28a745'; // Green color for ON state
  74. } else {
  75. toggleButton.textContent = 'Review Skip OFF';
  76. toggleButton.classList.remove('script-on');
  77. toggleButton.classList.add('script-off');
  78. toggleButton.style.backgroundColor = '#dc3545'; // Red color for OFF state
  79.  
  80. if (reloadOnDisable) {
  81. location.reload(); // Reload the page if the option is ON
  82. }
  83. }
  84. adjustCollapsibleButtonPosition();
  85. }
  86.  
  87. // Create the toggle button
  88. const toggleButton = document.createElement('button');
  89. toggleButton.textContent = 'Review Skip OFF'; // Initial text
  90. toggleButton.classList.add('toggle-button', 'script-off'); // Initial class for style
  91. toggleButton.addEventListener('click', toggleScript);
  92.  
  93. // Style the toggle button
  94. toggleButton.style.position = 'fixed';
  95. toggleButton.style.bottom = '20px';
  96. toggleButton.style.left = '20px';
  97. toggleButton.style.padding = '10px 20px';
  98. toggleButton.style.borderRadius = '30px'; // Make it round
  99. toggleButton.style.backgroundColor = '#dc3545'; // Red color for OFF state
  100. toggleButton.style.color = '#fff';
  101. toggleButton.style.border = 'none';
  102. toggleButton.style.cursor = 'pointer';
  103. toggleButton.style.fontFamily = 'Arial, sans-serif'; // Bubble-like font
  104. toggleButton.style.fontWeight = 'bold'; // Bold text
  105. toggleButton.style.fontStyle = 'italic'; // Italicized text
  106. toggleButton.style.fontSize = '14px'; // Adjust font size as needed
  107. toggleButton.style.zIndex = '9998'; // Ensure it's above other elements
  108.  
  109. document.body.appendChild(toggleButton);
  110.  
  111. // Create the collapsible button
  112. const collapsibleButton = document.createElement('button');
  113. collapsibleButton.innerHTML = '▼'; // Downwards arrow initially
  114. collapsibleButton.classList.add('collapsible-button');
  115. collapsibleButton.style.position = 'fixed';
  116. collapsibleButton.style.bottom = '80px'; // Default bottom position when collapsed
  117. collapsibleButton.style.left = '10px'; // Default left position
  118. collapsibleButton.style.padding = '5px';
  119. collapsibleButton.style.backgroundColor = 'transparent'; // No need to set initial background color
  120. collapsibleButton.style.color = '#fff';
  121. collapsibleButton.style.border = 'none';
  122. collapsibleButton.style.cursor = 'pointer';
  123. collapsibleButton.style.borderRadius = '50%'; // Round shape
  124. collapsibleButton.style.zIndex = '9999'; // Ensure it's above other elements
  125.  
  126. // Function to toggle visibility of the main toggle button
  127. collapsibleButton.addEventListener('click', function() {
  128. toggleButton.style.display = toggleButton.style.display === 'none' ? 'block' : 'none';
  129. adjustCollapsibleButtonPosition();
  130. });
  131. document.body.appendChild(collapsibleButton);
  132.  
  133. setInterval(clickSkipButtonContinuously, 1000);
  134.  
  135. function adjustCollapsibleButtonPosition() {
  136. if (toggleButton.style.display !== 'none') {
  137. collapsibleButton.innerHTML = '▼'; // Downwards arrow when expanded
  138. collapsibleButton.style.backgroundColor = 'transparent'; // Set back to transparent when expanded
  139. const rect = toggleButton.getBoundingClientRect();
  140. collapsibleButton.style.top = rect.top + 'px';
  141. collapsibleButton.style.left = rect.left + 'px';
  142. } else {
  143. collapsibleButton.innerHTML = '▲'; // Upwards arrow when collapsed
  144. collapsibleButton.style.backgroundColor = 'black'; // Change background color when collapsed
  145. collapsibleButton.style.top = 'auto';
  146. collapsibleButton.style.bottom = '20px';
  147. collapsibleButton.style.left = '10px';
  148. }
  149. }
  150.  
  151. adjustCollapsibleButtonPosition();
  152.  
  153. // Add Tampermonkey menu commands
  154. GM.registerMenuCommand("Toggle Reload on Disable (Current: " + (reloadOnDisable ? "ON" : "OFF") + ")", function() {
  155. reloadOnDisable = !reloadOnDisable;
  156. GM_setValue('reloadOnDisable', reloadOnDisable);
  157. alert("Reload on Disable is now " + (reloadOnDisable ? "ON" : "OFF"));
  158. });
  159. })();
  160.