GGn Select All Notifications

Add a "Select All" button to select all checkboxes for torrents on both the notifications page and delete notification page

  1. // ==UserScript==
  2. // @name GGn Select All Notifications
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @match https://gazellegames.net/torrents.php*action=delete_notify*
  6. // @match https://gazellegames.net/torrents.php*action=notify*
  7. // @description Add a "Select All" button to select all checkboxes for torrents on both the notifications page and delete notification page
  8. // @author SleepingGiant
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function addSelectAllButton() {
  16. var selectAllButton = document.createElement('button');
  17. selectAllButton.innerText = 'Select All';
  18.  
  19. // Add the 'button' class to apply the existing page styles
  20. selectAllButton.classList.add('button', 'input[type=submit]', 'input[type=button]');
  21.  
  22. var container = document.querySelector('.center');
  23.  
  24. if (container) {
  25. // Insert the button into the container
  26. container.appendChild(selectAllButton);
  27.  
  28. selectAllButton.addEventListener('click', function () {
  29. var checkboxes = document.querySelectorAll('input[type="checkbox"]');
  30. if (checkboxes.length > 0) {
  31. var allChecked = Array.from(checkboxes).every(checkbox => checkbox.checked);
  32. checkboxes.forEach(function (checkbox) {
  33. checkbox.checked = !allChecked;
  34. });
  35. }
  36. });
  37.  
  38. // Once the button is added, stop further retries
  39. clearInterval(intervalId);
  40. }
  41. }
  42.  
  43. // Retry adding the button every 100ms, up to 100 times
  44. let retryCount = 0;
  45. let maxRetries = 100;
  46. let intervalId = setInterval(function() {
  47. addSelectAllButton();
  48. retryCount++;
  49.  
  50. if (retryCount >= maxRetries) {
  51. clearInterval(intervalId);
  52. console.log('Max retries reached. Stopping attempts.');
  53. }
  54. }, 75);
  55. })();