Library for e-mail forward highlighting

Enable user scripts to highlight forwarded e-mails

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/40782/265774/Library%20for%20e-mail%20forward%20highlighting.js

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

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

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

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

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

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

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

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

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

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

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

function addStyles() {
    if (document.getElementById("email-quotes")) {
        console.log("Styles for e-mail quote highlighting already added, doing nothing");
        return;
    }
    console.log("Adding styles for e-mail quote highlighting");
    var styleNode = document.createElement('style');
    styleNode.setAttribute("type", "text/css");
    styleNode.id = "email-quotes";
    styleNode.innerHTML =
        'mark.quote1 { background: #eee }\n' +
        'mark.quote2 { background: #eef }\n' +
        'mark.quote3 { background: #efe }\n' +
        'mark.quote4 { background: #fee }\n' +
        'mark.quote5 { background: #ddd }\n' +
        'mark.quote6 { background: #ddf }\n' +
        'mark.quote7 { background: #dfd }\n' +
        'mark.quote8 { background: #fdd }\n';
    document.body.appendChild(styleNode);
}

function highlightQuotes() {
    addStyles();
    if (
        document.getElementsByClassName("quote1").length ||
        document.getElementsByClassName("quote2").length ||
        document.getElementsByClassName("quote3").length ||
        document.getElementsByClassName("quote4").length ||
        document.getElementsByClassName("quote5").length ||
        document.getElementsByClassName("quote6").length ||
        document.getElementsByClassName("quote7").length ||
        document.getElementsByClassName("quote8").length
    ) {
        console.log("E-mail quotes already highlighted, doing nothing");
        return;
    }
    console.log("Highlighting e-mail quotes");
    var context = document.querySelector("pre,blockquote,.Wordsection1,.MsoPlainText,body");
    var instance = new Mark(context);
    instance.markRegExp(/^(> *){1}([^>\n].*|)$/gm, {"className" : "quote1" });
    instance.markRegExp(/^(> *){2}([^>\n].*|)$/gm, {"className" : "quote2" });
    instance.markRegExp(/^(> *){3}([^>\n].*|)$/gm, {"className" : "quote3" });
    instance.markRegExp(/^(> *){4}([^>\n].*|)$/gm, {"className" : "quote4" });
    instance.markRegExp(/^(> *){5}([^>\n].*|)$/gm, {"className" : "quote5" });
    instance.markRegExp(/^(> *){6}([^>\n].*|)$/gm, {"className" : "quote6" });
    instance.markRegExp(/^(> *){7}([^>\n].*|)$/gm, {"className" : "quote7" });
    instance.markRegExp(/^(> *){8,}([^>\n].*|)$/gm, {"className" : "quote8" });
}