如何访问Firefox的Web控制台命令历史? [英] How to access firefox web console command history?
问题描述
取消devtools并按 在新的devtools窗口中,在控制台中键入以下命令: 我该怎么办在Firefox? 我不介意命令历史记录比google chrome长。 pastebin答案只有一天好。 Ctrl
+ Shift +
I
来检查devtools本身。 b
> location.origin
chrome-devtools:// devtools
> JSON.parse(localStorage.consoleHistory).join('\ n')
inp.style.backgroundColor =rgb(250,0,250)
inp.style.backgroundColor =rgb (250,255,250)
...
inp.style.backgroundSize
inp.style.backgroundColor
> JSON.parse(localStorage.consoleHistory).length
30
$ b $ pre $函数getWebConsolePanel(tab){
var gDevTools = Cu.import (resource:///modules/devtools/gDevTools.jsm,{})\
.gDevTools;
var tools = Cu.import(resource://gre/modules/devtools/Loader.jsm,{})。dev \
tools;
var target = tool.TargetFactory.forTab(tab || gBrowser.selectedTab);
var toolbox = gDevTools.getToolbox(target);
var panel = toolbox.getPanel(webconsole);
返回面板;
}
getWebConsolePanel();
现在您将看到当前所选标签页的Web控制台历史记录。
It is fairly easy to access the last 30 (!) javascript console commands in Google Chrome devtools:
Undock devtools and press Ctrl
+Shift
+I
in it to inspect devtools itself.
In that new devtools window, type following commands in the console:
> location.origin
"chrome-devtools://devtools"
> JSON.parse(localStorage.consoleHistory).join('\n')
"inp.style.backgroundColor = "rgb(250, 0, 250)"
inp.style.backgroundColor = "rgb(250, 255, 250)"
...
inp.style.backgroundSize
inp.style.backgroundColor"
> JSON.parse(localStorage.consoleHistory).length
30
How can I do the equivalent in Firefox?
I wouldn't mind if it had a longer command history than google chrome.
That pastebin answer was only good for a day. So here it is again, thanks @msucan!
function getWebConsolePanel(tab) {
var gDevTools = Cu.import("resource:///modules/devtools/gDevTools.jsm", {})\
.gDevTools;
var tools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).dev\
tools;
var target = tools.TargetFactory.forTab(tab || gBrowser.selectedTab);
var toolbox = gDevTools.getToolbox(target);
var panel = toolbox.getPanel("webconsole");
return panel;
}
getWebConsolePanel();
- Press F12 to open the developer toolbox (eg. the web console), then
- Switch to the Options panel.
- Enable chrome debugging.
- Open Scratchpad (Shift-F4).
- Copy/paste this code: https://pastebin.mozilla.org/3757211
- Go to Environment > Browser.
- Pick Execute > Display or Inspect.
And now you will see the web console history for the currently selected tab.
这篇关于如何访问Firefox的Web控制台命令历史?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!