friedow / centerpiece

Your trusty omnibox search.
MIT License
174 stars 6 forks source link

Feature request: firefox tabs #107

Open pinpox opened 3 months ago

pinpox commented 3 months ago

It would be awesome to be able to select firefox tabs, since I don't use brave.

friedow commented 3 months ago

This is only fitting since we have bookmarks and history in tickets already. The most interesting question for this is: Where are Firefox tabs stored at runtime?

nettybun commented 3 months ago

Firefox stores all open tabs, history, and bookmarks in the same places.sqlite database file in the Firefox user profile directory. It's partially documented here: https://firefox-source-docs.mozilla.org/browser/places/architecture-overview.html#storage

It should be safe to open the database with a new readonly connection and read out the tabs.

I know there's a risk of needing to keep SQL statements up to date as Firefox updates, but this is also a very old part of the codebase and I'd be surprised if they ever change the tables/columns.

friedow commented 3 months ago

Thank you @nettypurr! That should be an easy plugin then. Brave history is also stored in an sqlite database, so it should be mostly copy & past with some adjustments to the file location and query :).

pinpox commented 3 months ago

How does centerpiece make brave focus the correct tab after having selected it from the list of open ones?

friedow commented 3 months ago

We don't have an integration for Brave Tabs yet :P. But there is https://github.com/prasmussen/chrome-cli which might give some hints on how to do it because it can chrome-cli open <url> -t <id> (Open url in specific tab).

friedow commented 1 month ago

I've implemented a proof of concept for reading and displaying the firefox tabs on this branch: https://github.com/friedow/centerpiece/blob/feat/firefox-tabs/client/src/plugin/firefox/tabs.rs. This works differently then initially though. Turns out firefox does not save the current session in the places.sqlite file. Instead there is a lz4 compressed json file which needs to be read to get the currently open tabs.

However, I'm now stuck at the problem that there is no way to tell firefox to focus an open tab if a tab with the given url already exists. Any ideas?