Mail spam timeout countdown

Отсчитывает секунды после в `Сообщение может быть отправлено через N секунд.`

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         Mail spam timeout countdown
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Отсчитывает секунды после в `Сообщение может быть отправлено через N секунд.`
// @author       Something begins
// @license      None
// @match       https://www.heroeswm.ru/sms-create.php*
// @match       https://my.lordswm.com/sms-create.php*
// @match       https://www.lordswm.com/sms-create.php*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

const allFonts = document.querySelectorAll("font");
const warningMessageFontArr = Array.from(allFonts).filter(font => {return font.textContent.includes("Сообщение может быть отправлено")});
const warningMessageFont = warningMessageFontArr.length !== 0 ? warningMessageFontArr[0] : false;
const seconds = parseInt(warningMessageFont.textContent.match(/\d+/)[0]);
console.log(seconds);
function getNthParent(ele, N){
    if (N <= 1) return ele;
    else{
        return getNthParent(ele.parentElement, N-1);
    }
}
function tickTock(seconds){
    if (seconds <= 0) {
        warningMessageFont.textContent = "Сообщение можно отправлять.";
        warningMessageFont.style.color = "green";
    }
    else {
        setTimeout(()=>{
            const nextSeconds = seconds - 1;
            warningMessageFont.textContent = warningMessageFont.textContent.replace(seconds.toString(), nextSeconds.toString());
            tickTock(nextSeconds);
        }, 1000);
    }
}
warningMessageFont && tickTock(seconds);