Dashboard auto-refresh

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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();
})();