1

While trying to extract information from a web page, I tend to use the console in the web developer tools to write some simple javascript to get the DOM elements and capture the data I need.

I tend to treat the web developer console as an REPL and I would like to save those code snippets for possible re-use in the future. Spark repl has a very useful command :save which saves all the commands from the session to a file so I can replay it later.

Is there such a feature in firefox web developer console to save the commands in the current console session?

I couldn't find any mention of such thing in the user documents. My google search and stack overflow search also turned empty. Only thing I've come close to is Scratchpad, which can be enabled from the web developer tools settings, but it doesn't seem to fit my need.

Sundeep
  • 1,536
  • 5
  • 23
  • 35
  • Chrome enables you to right-click > Save as... – Sébastien Jun 20 '20 at 22:59
  • 1
    But you cannot replay what you save in Chrome, because it includes the return values and the `VM733:1` type annotations... It's meant for saving logs. Nice question, I'd like to know too – blex Jun 20 '20 at 23:03
  • @Sébastien I use Firefox as primarily, so it would be great to have this feature in Firefox, but Chrome is also an acceptable alternative for me. However, when I just tried this, Chrome only allowed me to select one of the commands in the session and on it's context menu, I could see `Save as...`. Is there some way to save the entire session instead of just one command selectively? – Sundeep Jun 20 '20 at 23:07
  • 1
    Just found a [workaround for Chrome](https://stackoverflow.com/a/51802737/1913729), but it's really tedious It involves undocking the console, and then opening the console of the console itself, and then getting the input history as JSON from localStorage – blex Jun 20 '20 at 23:13
  • @blex Interesting find! Does it work for you? It doesn't seem to work for me on Chrome `Version 83.0.4103.106 (Official Build) (64-bit)` on Mac. I couldn't find any entries in `localStorage` either – Sundeep Jun 20 '20 at 23:19
  • 1
    I have the exact same version of Chrome as yours, but on Windows 10. It works on my machine™ – blex Jun 20 '20 at 23:22

0 Answers0