Mail recievers

Adds recievers to your mail inbox

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Mail recievers
// @namespace    http://tampermonkey.net/
// @version      2024-11-03
// @description  Adds recievers to your mail inbox
// @author       You
// @match        https://www.warzone.com/Discussion/MyMail*
// @grant        none
// ==/UserScript==

(function() {
    let rows = document.getElementsByClassName("region")[0].tBodies[0].rows;
    for (let row of Array.from(rows).slice(1)) {
        processRow(row);
    }

    async function processRow(row) {
        let children = row.cells[0].children;
        if (children) {
            let url = children[0].href;
            let toLine = "\nsend to: " + await getNames(url);
            children[2].innerText += toLine;
        }
    }

    async function getNames(url) {
        let parser = new DOMParser();
        let names = [];
        let doc = await fetch(url).then(reply => reply.text()).then(text => parser.parseFromString(text, 'text/html'));
        let cell = doc.getElementsByTagName("Table")[0].rows[0].cells[0];
        for (let child of Array.from(cell.children).slice(2)){
            if (child.tagName == "BR") break;
            names.push(child.innerText.trim());
        }
        return names.join(", ");
    }
})();