2012-07-12 106 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()調用仍會出現,網頁所做的任何操作仍會顯示。)