I’ve just finished writing a simple add-on for Thunderbird 60.9.0 that, upon sending an email, performs a global replace of all html blockquote tags for div tags in the email body.
I did this because I’m sick of the intending that occurs due to the use of blockquote tags. My emails have no indenting when I view them myself (due to me using the ReplyWithHeader add-on which hides the indenting) however all my friends/colleagues who use Outlook still see the indenting, and worse, when they reply to me the indenting reappears at my end (i.e. it is no longer hidden). It drives me nuts!
Anyway, my add-on is working well (first add-on I’ve written). The code I used is below. I just wanted to get some feedback from the community as to whether what I’ve done is the best and/or most sensible way to achieve this result.
Thank you all.
function send_event_handler(event) {
var msg_compose_window = document.getElementById("msgcomposeWindow");
var msg_type = msg_compose_window.getAttribute("msgtype");
if (! (msg_type == nsIMsgCompDeliverMode.Now || msg_type == nsIMsgCompDeliverMode.Later)) return;
try {
var editor_type = GetCurrentEditorType();
if (! (editor_type == "html" || editor_type == "htmlmail")) return;
var editor = GetCurrentEditor();
editor.beginTransaction();
var body = editor.outputToString('text/html', 2);
body = body.replace("<blockquote", "<div", "g");
body = body.replace("blockquote>", "div>", "g");
editor.rebuildDocumentFromSource(body);
editor.endTransaction();
} catch (e) {
Components.utils.reportError(e);
return false;
}
}
window.addEventListener("compose-send-message", send_event_handler, true);