Greasy Fork is available in English.

Tournament Inviter

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

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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)
})();