Dashboard auto-refresh

Automatically refresh your Multi-Player dashboard by re-applying your currently selected games filter.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Dashboard auto-refresh
// @namespace    http://tampermonkey.net/
// @version      2025-05-20
// @description  Automatically refresh your Multi-Player dashboard by re-applying your currently selected games filter.
// @author       JK_3
// @match        https://www.warzone.com/MultiPlayer/
// @icon         https://icons.duckduckgo.com/ip2/warzone.com.ico
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const secondsBetweenRefreshes = 30;

    function ScheduleRefresh() {
         setTimeout(RefreshFilter, secondsBetweenRefreshes * 1000);
    }

    function GetFilterPrompt() {
        return document.getElementById("AlertVMPrompt_Inner");
    }

    function RefreshFilter()
    {
        function SelectFilterOption(filterText) {
            let prompt = GetFilterPrompt();
            if (prompt) {
                let btn = Array.from(prompt.querySelectorAll("input")).filter(i => i.value.startsWith(filterText)).at(0);
                setTimeout(() => btn.click(), 300); // WZ is slow when adding event handlers, so we need to wait with clicking
                ScheduleRefresh();
            } else {
                setTimeout(() => SelectFilterOption(filterText), 25);
            }
        }

        let filterBtn = document.getElementById("MyGamesFilterBtn");
        if (filterBtn) {
            if (!GetFilterPrompt()) {
                filterBtn.click();
            }

            SelectFilterOption(filterBtn.innerText.slice(8, -3));
        }
    }

    ScheduleRefresh();
})();