2012-07-12 107 views
1

有没有办法清除错误控制台从userscripts GM_log消息在某些事件?清除GM_log从错误控制台

我不想手动清除。 On trigger of certain event, want to clear up the old log from the error console and show up the new log.

回答

1

您无法清除the error console。如果可以的话,邪恶的网站也可以清除它,并抹去他们的不当行为记录。

反正你不应该再使用GM_Log()Use Firebugthe excellent console logging functions it provides。您可以使用console.clear()

请注意,为避免与Firefox的新功能console功能发生冲突,并确保输出显示在Firebug的控制台中,您可能需要以unsafeWindow为前缀调用。

所以,你的脚本可以做这样的事情:

unsafeWindow.console.clear(); 
unsafeWindow.console.time ('ScriptRun'); 

unsafeWindow.console.log ("Script start."); 
unsafeWindow.console.timeEnd ('ScriptRun'); 


看起来像这样在Firebug控制台其中:
Console result

- 与上述所有冗余代码删除。 (尽管clear()调用仍会出现,网页所做的任何操作仍会显示。)