Can I control my firefox browser externally (from CLI or make an app) ?
I would like to be able to perform the following actions from outside the browser, for example from a script
'''
Obtain a list of all tabs, and which URL is open
Obtain a list of all firefox windows and which tab is in each and in what order
Obtain a list of firefox running instances
Actions on tabs
Close a tab
Open a new tab and enter URL
move a tab in a window's tab order
move a tab to another window
mute/unmute a tab
make a tab hidden or unhide
pin/unpin a tab
select/unselect a tab
discard a tab
reload a tab
copy tab body or a specific xpath
run a javascript cmdlet, (bookmarklet ? )
Run a function of a script in somethingmonkey
bookmarks
list all bookmarks folder and bookmarks
move a bookmark to another folder
delete a bookmark
create a bookmark
get/change position of a firefox window
close a window/ open a new window
list installed addons
turn an addon on or off
'''
I would love to be able to write script, from outside firefox, and do these actions
I have found about the remote debugger, but I can't figure out if it's only for debugging firefox on android via adb ? Or can I use that directly from a script ?
Yes that is likely possible. Firefox uses SQL databases, json files, and more complex stuff to store all its data.
Reading data is possible but complex. Opening windows is done via CLI interface. Moving the windows is part of your compositor and not Firefox, like KWin on KDE.
I think it would be much cleaner to make an addon that does this within the browser and exposes the functionality as a web API (or failing that, connects to a relay server locally). Then you can just use curl to send it commands.
You can look at how KDE Connect / Plasma Browser Integration does it, it does very similar things to integrate with Plasma like go to a tab via KRunner.
Also I specifically want that from the console. The console is the universal tgat doesn't require using some particulat language, or even programming at all