Dashboard auto-refresh

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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