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?

+1


a source to share


2 answers


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).

+1


a source


I think you will find that some messages are loaded when they are listed in the stream; hence your problem.



Why don't you just use your own style? UserStyles FF plugin.

0


a source







All Articles