Tournament Inviter

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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)
})();