Your JavaScript in Thunderbird – Manipulate Shown Email Contents with Developer Console

You can run Javascript interactively in Thunderbird. It containts a developer toolbox, similar to Firefox F12 console.
In this short example, we change some text on the message being viewed.
With Firefox, I have used similar content manipulation to fix broken websites and to see translations in every Wikipedia page.

Developer Toolbox

In Thunderbird, open Tools: Developer Tools: Developer Toolbox.
Allow “Incoming Connection” “Client .. 127.0.0.1” “Server 127.0.0.1” “Allow connection?” OK.

Run JavaScript Interactively

In Console

>> document.getElementById("messagepane").contentDocument.body.innerHTML

Shows HTML of the current message, the one being viewed in the message pane.
To find element ids, use the Inspector tab in the Developer Toolbox.
You have all JavaScript at your hands

>> s=s.replace(" and ", " FOOBAR ", )

Many elements can be directly manipulated:

>> document.getElementById("messagepane").contentDocument.body.innerHTML=s

Current message on Thunderbird UI is modified, one ” and ” is changed to ” FOOBAR “.
This change is (hopefully) cosmetic, and does not change the stored copy of the message.

Discussion

What would you do with this ability? With Firefox, I have used similar content manipulation to fix broken websites and to see translations in every Wikipedia page. With email, making simple corrections to emails or adding some piece of important data from another system could make life a lot easier.
Firefox is moving to Chrome style AddOns and obsoleting XUL addons. It is not certain when or if Thunderbird will make this change.

Adminstrivia

This article has been updated multiple times.

Posted in Uncategorized | Tagged , , , , , , , , | Comments Off on Your JavaScript in Thunderbird – Manipulate Shown Email Contents with Developer Console

Comments are closed.