从错误控制台清除GM_log

时间:2012-07-12 03:16:29

标签: firefox greasemonkey

有没有办法从某个事件的用户脚本中清除错误控制台中的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 个答案:

答案 0 :(得分: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()电话会在{{1}}通话后仍然显示任何内容。)