Mail spam timeout countdown

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

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 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         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);