Greasemonkey and Gmail - parsing message content
I want to read the contents of Gmail messages and add some link attachments. Here is the code:
unsafeWindow.gmonkey.load("1.0", function(gmail){
gmail.registerViewChangeCallback(function(){
if (gmail.getActiveViewType && gmail.getActiveViewType() == "cv") {
var viewElement = gmail.getActiveViewElement()
// Do things with viewElement
}
})
})
The actual detection of links in dom objects for emails is the easy part. The problem is that registerViewChangeCallback
only works when displaying a stream. Large streams will have most messages hidden just for the user to download. I have not found the Gmail greasemonkey API for this specific action (loading an individual message), namely when I need to run my script.
Any suggestions?
a source to share
As you say, the registerViewChangeCallback () function only fires when the user changes their view, eg. streams to archives, etc.
What you really need is to add a feature that intercepts Gmail emails and then modifies links. I've never tried doing this myself, but this answer contains some sample code. When gmail receives a new message, it will fire an event readystatechange
that your code can intercept. Then you can change the content of the message anyway (although it might take you a while to let gmail insert the message first - not sure about that).
a source to share