9

I've been trying to find a method to export all my currently open tabs in the Android Firefox browser. Unfortunately this seem impossible from default browser installation and very hard to do from command line as the SQLite3 database that Firefox is using, contains too many tables and hard to find the right query.

Apparently this is possible for Google Chrome using THESE hacks.

I would like to have each URL on a separate line in a text file.

6

Note: this solution requires a rooted Android.

In a terminal emulator app, execute:

(Requires Busybox if running Android 5.1.1 or below. For Marshmallow, remove the term busybox from the following command.)

su
content query --uri content://org.mozilla.firefox.db.tabs/tabs/ --projection url | busybox cut -d '=' f 2 > /sdcard/firefox_tabs.txt

Explanation of the second command:

  • content query: to query a Content Provider
  • org.mozilla.firefox.db.tabs: a content provider from Firefox.
  • --projection url: list data from the url column only

(Click image to enlarge)

IMG:

Or if you have the sqlite3 tool in Android, then you can do:

su
sqlite3 /data/data/org.mozilla.firefox/files/mozilla/*.default/browser.db "SELECT url FROM tabs ORDER BY position" > /sdcard/firefox_tabs.txt 

I've assumed that you have a single Firefox profile and its name has not been altered. If you've a multi-profile setup or if you did change the profile's name, then instead of *.default provide the correct name of the profile of whose tabs you want in your list.

| improve this answer | |
  • Tested on Firefox v45.0.2. – Firelord Apr 27 '16 at 16:55
  • Amazing. Worked perfectly! I also learned something new, how to use the content query. – not2qubit Apr 29 '16 at 7:54
  • 3
    file path might change as of 2018: myphone:/data/user/0/org.mozilla.firefox/files/mozilla/1...f.default – TiloBunt Apr 9 '18 at 5:10
6

On Android system you can use Termux (No root required):

  1. Navigate in Firefox to URL: file:///data/data/org.mozilla.firefox/files/mozilla/
  2. Choose the link of ***.default folder of your profile
  3. Choose the sessionstore.js file
  4. Copy content of this file and save it in sessionstore.js file on local storage
  5. Run the command in Termux to output your tabs urls:

    cat ~/storage/shared/sessionstore.js | sed -n 's@{\"url\":\"@&\n@g; s@\",\"title\"@\n@gp' | sed '/^[:{]\"/d'
    

    Or, this command to save your tabs urls in file sessionstore.txt on your local storage:

    cat ~/storage/shared/sessionstore.js | sed -n 's@{\"url\":\"@&\n@g; s@\",\"title\"@\n@gp' | sed '/^[:{]\"/d' > ~/storage/shared/sessionstore.txt
    
| improve this answer | |
  • This is genius! Thank you so much! – balu May 13 at 15:29
  • UPDATE: While I thought at first that this would work, it actually doesn't: Copying the sessionstore.js's content won't work if the file is sufficiently large. In that case, the clipboard will only contain the first X characters of the file. Not sure if this is caused by Firefox or by Android but in any case it doesn't work. Unfortunately, Firefox for Android doesn't provide a "Save page as…" or "Save target as…" feature, so simply "downloading" the file is not possible, either. Can't make this shit up. – balu Jun 25 at 17:11
4

Apparently there is an Android specific Firefox browser plug-in called Tabs Backup. This seem to work like charm! It places a text file in /storage/emulated/0/Android/tabs_backup/ (Aka. /sdcard/Android/tabs_backup/) called backup_DDMMYYY_hhmmss.txt.

However, it would still be interesting to know how to do this from command line.


UPDATE: 2018-08-15

Since some time back, Tabs Backup no longer works for the recent versions of Android Firefox. Instead, use Tabs Export. You also need a separate plugin, to import Tabs.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.