whatnowmax / zendesk_populate_tab_with_id

// ==UserScript==
// @name zendesk_populate_tab_with_id
// @description populate zendesk tab
// @version 1.0
// @author whatnowmax
// @license MIT
// @match        https://advsysconsupport.zendesk.com/agent/tickets/*
// @run-at document-end
// @grant none
// ==/UserScript==


(function() {
    setTimeout(() => {
        var intervalId = setInterval(function() {
            console.log("loop started.");
            var title = document.title;
            var regex = /^[0-9]/;
            if (title.match(regex)) {
                //clearInterval(intervalId);
            } else {
                const caseNum = location.href.match(/\d+$/)[0]; //case number at the end of the title
                const originalTitle = document.title;
                const modifiedTitle = originalTitle.replace(/^Ticket: /, "");
                document.title = caseNum + " - " + modifiedTitle;
            }
        }, 1000);
}, 1000);
})();