brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Ctrl+B turns the Firefox console into a multi-line editor

Firefox
~/tips/tip-firefox-multiline-console

Windows and Linux: Ctrl+B

Write longer snippets in the console without Enter running them too early.

Typing a loop into a one line console is fiddly: press Enter at the wrong moment and half your code runs. Firefox has an editor mode for exactly this.

With the Web Console focused, press:

Windows and Linux: Ctrl+B
Mac: Cmd+B

The input moves to a pane on the left. Enter now makes a new line, and you run the whole thing with Ctrl+Enter (Cmd+Enter on a Mac) or the Run button. Your code stays in the editor after it runs, so you can fix one line and run it again.

for (const a of document.querySelectorAll('a[target="_blank"]')) {
  console.log(a.href);
}

That lists every link on the page that opens a new tab, and tweaking the selector is a one second job. The output appears next to the editor, so both stay in view.

Press the same shortcut again to go back to the single line prompt. I use the editor for quick experiments only: it is not saved as a project file, so copy anything you want to keep into a real file before you close up. On a narrow DevTools window the side by side layout gets cramped, and docking it wider helps.

Further reading: Firefox DevTools: the JavaScript input interpreter

More Firefox tips view-source:https://www.mozilla.org/#line100 ^ invoice history about:processes right-click the request > Edit and Resend Inspector > click the "grid" badge All Firefox tips (10) All topics

Link