Tournament Inviter

Provides context menu commands for inviting players (from a clan) to a tournament

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Tournament Inviter
// @namespace    http://tampermonkey.net/
// @version      2025-12-14
// @description  Provides context menu commands for inviting players (from a clan) to a tournament
// @author       JK_3
// @match        https://www.warzone.com/MultiPlayer/Tournaments/Forward?ID=*
// @icon         https://icons.duckduckgo.com/ip2/warzone.com.ico
// @grant        GM_registerMenuCommand
// ==/UserScript==

(function() {
    'use strict';

    function getNextButton() {
        let iterator = document.querySelector("div[id^='ujs_PagingContainer']")?.querySelectorAll(".ujsBtn")
        if (iterator)
        {
            for (let btn of iterator) {
                if (btn.textContent.includes("Next")) {
                    return btn.querySelector("[id$='_btn']")
                }
            }
        }

        return null
    }

    function inviteAllPlayers() {
        for (let btn of document.querySelectorAll("[id^='ujs_InviteBtn_'][id$='_btn']")) {
            btn.click()
        }

        let nextBtn = getNextButton()
        if (nextBtn) {
            nextBtn.click()
            inviteAllPlayers()
        }
    }

    function inviteActivePlayers() {
        for (let img of document.querySelectorAll("[id^='ujs_OnlineImage'][id$='img']")) {
            if (img.checkVisibility()) {
                img.parentElement?.parentElement?.parentElement?.querySelector("[id^='ujs_InviteBtn_'][id$='_btn']")?.click()
            }
        }

        let nextBtn = getNextButton()
        if (nextBtn) {
            nextBtn.click()
            inviteActivePlayers()
        }
    }

    GM_registerMenuCommand("Invite all", inviteAllPlayers)
    GM_registerMenuCommand("Invite active players only", inviteActivePlayers)
})();