在Greasemonkey中,您不能完全使用这种语法,但类似的内容应该可以满足您的需要:
function UpgradeCheckFunction ()
{
//--- Put payload code here.
alert ("I just ran an an upgrade check?!");
}
.
然后定义
PerformOnceAcrossTabs()
,就像这样:
function PerformOnceAcrossTabs (sName, oFunction)
{
var OldValue = GM_getValue (sName);
if (OldValue)
{
//--- Optionally also do a timestamp check and clear any "locks" that are X hours old.
return;
}
GM_setValue (sName, new Date().toString() );
//--- run payload function here.
(oFunction)();
//--- Clear "Lock".
GM_deleteValue (sName);
}
.
那就这样说吧:
PerformOnceAcrossTabs ("UpgradeCheckLock", UpgradeCheckFunction);