GGn Select All Notifications

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         GGn Select All Notifications
// @namespace    http://tampermonkey.net/
// @version      1.1
// @match        https://gazellegames.net/torrents.php*action=delete_notify*
// @match        https://gazellegames.net/torrents.php*action=notify*
// @description  Add a "Select All" button to select all checkboxes for torrents on both the notifications page and delete notification page
// @author       SleepingGiant
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function addSelectAllButton() {
        var selectAllButton = document.createElement('button');
        selectAllButton.innerText = 'Select All';

        // Add the 'button' class to apply the existing page styles
        selectAllButton.classList.add('button', 'input[type=submit]', 'input[type=button]');

        var container = document.querySelector('.center');

        if (container) {
            // Insert the button into the container
            container.appendChild(selectAllButton);

            selectAllButton.addEventListener('click', function () {
                var checkboxes = document.querySelectorAll('input[type="checkbox"]');
                if (checkboxes.length > 0) {
                    var allChecked = Array.from(checkboxes).every(checkbox => checkbox.checked);
                    checkboxes.forEach(function (checkbox) {
                        checkbox.checked = !allChecked;
                    });
                }
            });

            // Once the button is added, stop further retries
            clearInterval(intervalId);
        }
    }

    // Retry adding the button every 100ms, up to 100 times
    let retryCount = 0;
    let maxRetries = 100;
    let intervalId = setInterval(function() {
        addSelectAllButton();
        retryCount++;

        if (retryCount >= maxRetries) {
            clearInterval(intervalId);
            console.log('Max retries reached. Stopping attempts.');
        }
    }, 75);
})();