GGn Select All Notifications

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
})();