Firstly, you can yell at Google to fix their gmail-greasemonkey API, which seems to break more every day. In particular, registerViewChangeCallback() will make the solution easier, but it seems to have stopped working correctly.
A workaround would be to delay the change of the main document changes. The following code seems to work for me in Firefox. You may need to change your iFrame content settings.
// // ==UserScript== // @name Fire on page finished (with AJAX mods) // @namespace Gmail // @description This script shows one way to wait for an AJAX-heavy page to load. // @include http://mail.google.com/* // @include https://mail.google.com/* // ==/UserScript== // if (window.top != window.self) //don't run on frames or iframes return; var zGbl_PageChangedByAJAX_Timer = ''; window.addEventListener ("load", LocalMain, false); function LocalMain () { if (typeof zGbl_PageChangedByAJAX_Timer == "number") { clearTimeout (zGbl_PageChangedByAJAX_Timer); zGbl_PageChangedByAJAX_Timer = ''; } document.body.addEventListener ("DOMNodeInserted", PageBitHasLoaded, false); } function PageBitHasLoaded (zEvent) { if (typeof zGbl_PageChangedByAJAX_Timer == "number") { clearTimeout (zGbl_PageChangedByAJAX_Timer); zGbl_PageChangedByAJAX_Timer = ''; } zGbl_PageChangedByAJAX_Timer = setTimeout (function() {HandlePageChange (); }, 666); } function HandlePageChange () { removeEventListener ("DOMNodeInserted", PageBitHasLoaded, false); alert ('Page has finished loading.'); }
Brock adams
source share