How to catch GMail auto update

I wrote userscript to highlight the current line in GMail (indicated by an arrow). Unfortunately, the highlight will only remain until the GMail subfolder is automatically updated, which happens quite often. Is there a way to catch this event so that I can reapply the highlight? I do not want to do this with a timeout. There is another user script that does this, and it loads the CPU.

+3
source share
4 answers

It seems to me that you will want to view this document, which is the documentation for the Gmail gmonkey API , which is the API that Google provides greasemonkey scripts for.

This page describes custom text that tracks changes in views , and it should be very similar to what you need.

I assume you need 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);
+2
source

If you add a timer and watch when the highlight element disappears? or if the parent has changed its address (using ===).

+1
source

CSS (http://userstyles.org/) . Firefox DOM HTMl , CSS, .

0

gmail , https://cleverinsert.com/, gmail. , . MutationSummary , . , .

-summary.js

new MutationSummary({
  callback: render,
  rootNode: document.querySelector('.AO'),
  observeOwnChanges: false,
  oldPreviousSibling: true,
  queries: [
      { element: 'td.xW' }
  ]});

function render(a) {
  console.log("callback triggered");           
}
0

Source: https://habr.com/ru/post/1736848/


All Articles