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();