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