首先,你可以在Google上大喊,修正他們的gmail-greasemonkey API - 這似乎每天都會有更多的突破。具體而言,registerViewChangeCallback()
將促進解決方案,但它似乎已停止正常工作。
解決方法是延遲主文檔更改。下面的代碼似乎爲我工作,在Firefox上。它可能需要調整iFrame內容。
//
// ==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.');
}
似乎到目前爲止工作!謝謝。而且,API是更好的方法。希望有一天他們會復活。 – Alec 2010-08-23 20:27:00