I want to catch the moment when everything on the page mail.google.com zagrizolos

the usual jquery or native js with their events work out a little, and sometimes much earlier, than the page really loaded.

I am writing a gmail plugin, and I only need to load elements onto the page after a full load and screw the logic.

Does someone have any ideas, or can someone come across?

  • Where are you catching? - UserName
  • from content-scripts in extension - Artem Ekzarho

1 answer 1

You can intercept the message event:

 window.addEventListener('message', function onMessage(e) { console.log(e); if (typeof e.data !== 'string') return; try { var data = JSON.parse(e.data); } catch (err) { return; } if (/ready/.test(data.s)) { window.removeEventListener('message', onMessage); onGmailLoaded(); } }); function onGmailLoaded() { if (/No new mail!/.test(document.body.innerHTML)) console.log('Oops!'); } 

console

The alternative is to periodically check for the presence of any DOM element that appears only after a full load.