Skip to content

Instantly share code, notes, and snippets.

@dpschen
Last active September 19, 2024 23:17
Show Gist options
  • Save dpschen/f13399a880f1e0bf5a968a5aab6d8692 to your computer and use it in GitHub Desktop.
Save dpschen/f13399a880f1e0bf5a968a5aab6d8692 to your computer and use it in GitHub Desktop.
Hacky way to export synced tabs of Firefox Sync / Weave and import them in OneTab

Hacky way to export synced tabs of Firefox Sync / Weave and import them in OneTab

Background

I am guilty beeing a tab messy and was searching for a while for a good solution to move my open tabs to OneTab. Especially on mobile the tab situation was extremely bad. When I realized that I had over 3000 (!!) tabs on my iPhone opened I acknowledge that I got to do something.

First I tried to just open the tabs in Firefox. When you rightclick a device on the "Synced Tabs" sidebar there is an "Open all tabs" entry. For 3000 tabs already my computer was already overloaded when opening them… Closing every other open program and removing every browser extension other then blockers also didn't do the trick. After some time the tabs seemed to be in an open state, but Firefox was not really responding. I tried closing the tabs via OneTab and also to save them all as bookmark via Bookmarks -> Bookmark all Tabs but that also didn't work.

So I played around with various accessible API implementations. After a few hours I almost gave up. The libraries that I found were either that old that installing was really complex (old dependencies) or I couldn't get past the authorization.

So that's how I ended up getting the data that I wanted by using this ugly trick:

Steps

  1. Download and install "About Sync" Firefox extension https://addons.mozilla.org/en-US/firefox/addon/about-sync/ This extension is made for debugging the Firefox Sync.

  2. Navigate in Firefox to about:sync (Since this is not a valid URL, a markdown link is not possible)

  3. Go to the Firefox Debugger and add response under Watch Expressions and add a breakpoint to the fetchCollection function in the line where the response variable gets declared.

  4. Click the "Refresh" button on the page

  5. Resume through breakpoints until response.url is the tab endpoint of the api. Will be something like https://sync-1-us-west1-g.sync.services.mozilla.com/1.5/143199178/storage/tabs?full=1&limit=1000

  6. The expression variable is now declared in the console. Go there.

You can inspect the data with:

console.log(response)

Copy the urls of the tabs to the clipboard in a format that is understandable by the OneTab import:

// this is the index of the record (aka synced device)
const SYNCED_DEVICE_INDEX = 1;

const { tabs } = response.records[SYNCED_DEVICE_INDEX].cleartext

// format to OneTab CSV
const oneTabEntries = tabs
  .map(({ urlHistory, title, lastUsed }) => {
    return urlHistory[0] + ' | ' + title + ', ' + lastUsed
  })
  .join(('\n'))

// copy to clipboard
copy(oneTabEntries)
@dpschen
Copy link
Author

dpschen commented Dec 30, 2022

Thank for shating this! I didn't undetstand how to do the third point, but get JSON string w/ tabs, and wrote page to convert it to Onetab format, who interested - can see github.com/FreeWebber/SyncedJSONtoOnetab

Happy that this was helpful 👍

I added a link to the Firefox documentation on how to set Watch Expressions

@KaliszAd
Copy link

Here is probably an even simpler guide: https://stackoverflow.com/questions/50829318/export-synced-tabs-in-firefox it uses About Sync too (beware, after installing, you have to restart the browser).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment