views:

305

answers:

3

I wrote a userscript to highlight the current row in GMail (indicated by the arrow). Unfortunately the highlight will only stay until GMail Inbox is auto-refreshed, which happens quite often. Is there a way to catch that event so I could reapply the highlighting? I don't want to do it on timeout. There is another userscript that does that and it loads up CPU.

+1  A: 

If you add a timer and look when your highlight element disappear? or if a parent object change its address (with ===).

sw
Yep, that's what I said I DON'T want to do - use timer. Try it, you'll see CPU usage hovering just under 50%.
nameanyone
+2  A: 

It sounds to me like you will want to review this document which is documentation for the Gmail gmonkey API, which is an API that google provides for greasemonkey scripts.

This page describes a userscript which monitors view changes, and this should be very similar to what you need.

I assume you will want something like:

window.addEventListener('load', function() {
  if (unsafeWindow.gmonkey) {
    unsafeWindow.gmonkey.load('1.0', function(gmail) {
      function changedViewType() {
        // Threadlist
        if(gmail.getActiveViewType()== "tl"){
          // code to highlight the current row here...
        }
      }
      gmail.registerViewChangeCallback(changedViewType);
      changedViewType();
    });
  }
}, true);
Erik Vold
I finally got around to checking this and it doesn't work. Neither does the sample script on that page, Gmail View Watcher.
nameanyone
Gmail Greasemonkey API abandoned? See http://code.google.com/p/gmail-greasemonkey/issues/detail?id=39
nameanyone
A: 

consider a CSS userstyle (http://userstyles.org/ ) instead of a userscript. You can use Firefox's DOM inspector to look at the HTMl elements and classes in the selected row, and then it should be pretty straightforward to write a CSS selector that select just that row.

ryan
ryan, the question is how to catch an event. I have no problem selecting a row.
nameanyone