Simple-tab-groups: Add Firefox Sync support

Created on 17 Nov 2018  Â·  39Comments  Â·  Source: Drive4ik/simple-tab-groups

The automatic backup of the tab groups is a very useful feature, but currently it is only usable in a single PC configuration, due to the fact that the backups are saved in the Downloads folder. Would it be possible to add the same functionality using Firefox Sync?

Most helpful comment

Hi all! I added option to export groups to bookmarks, you can sync groups/bookmarks this way
https://github.com/Drive4ik/simple-tab-groups/issues/328#issuecomment-466117650

All 39 comments

I was wondering whether it would be possible to synchronise tab groups using Firefox Sync, too. My idea was to sync them as bookmarks (loosing history, but that is OK for me), potentially storing the group names in tags (allows having the same tab belong to multiple groups) or using bookmark folders (allowing just one group per tab, if that is more desirable from a design / implementation perspective).

+1
Alternatively, if someone would figure out if/how we can sync hiddent tabs, that might solve this issue. But native support by the extension would be ace, I use sync a lot - opening work content at home, and vice versa.

Hi all, I have been trying to implement this for a long time, but there is a restriction:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/sync

You can store up to 100KB of data using this API. If you try to store more than this, the call will fail with an error message.

If you have a lot of tabs, the data size will be more than 100KB. And then the problem, the solution of which adds only more problems ...

Is there any way to make us see the total of all tabs in Firefox sync? Because when I move tabs to groups, on my other device I only see tabs which are in the open group, tabs from other groups are not shown and hence inaccessible.

As a use case, I use groups at work to group my work-related tabs into logical parts. When I get home and want to come back to some of my work tabs, I only see the active group tabs in my synced tabs, and other tabs are only accessible from my work device.

I understand that synchronizing all tabs seems difficult, but it would be nice if at least we can synchronize groups and settings

The solution is to allow backup of groups to bookmarks as in #328, that way you have 100KB data in firefox sync to store configuration.

Hi all! I added option to export groups to bookmarks, you can sync groups/bookmarks this way
https://github.com/Drive4ik/simple-tab-groups/issues/328#issuecomment-466117650

Sorry, maybe I'm dumb, but I don't understand how I should use the new bookmark export to resolve syncing use cases. Can I set it up so that all my groups are periodically automatically bookmarked? Or can I only do it manually for each group?

@hluposti you're quite right in that, this is not an automatic process.

Can I set it up so that all my groups are periodically automatically bookmarked?

Not currently, but maybe the author is working on some magic here :)

Or can I only do it manually for each group?

Currently this is the case.

The current implementation in #328 is not fully automatic. It can backup automatically, but not restore automatically. So it's not really a sync though it can kind of be used that way in a manual process. To implement sync functionality using #328, the author would need to use the functionality implemented in #328 a little bit differently.

One potential design approach would be to create a "SimpleTabGroupsSync" BookMark Folder, which STG would then automatically write all current STG Window groups. Second he would need to read this group if it exists on startup to make sure that the sync'ed bookmarks and the the current STG window groups match. To do this requires solving several hard computer science problems, something similar to a "cache invalidation" problem. He would have to keep a hash of every item in each STG window group to make sure existing items are updated and only new items are created, and vice versa. Or he can just start from scratch each time. It gets into the weeds quickly to try to implement this. He could potentially calculate a hash on the STGSync Bookmarks folder, or perhaps access a last sync'ed timestamp to know when he needs to update groups in STG from newly sync'ed bookmarks. The point is that this new implementation would require a private "STGSync BookMark Folder" which wouldn't be meant for any manual user interaction, which is how the current sync feature in #328 is implemented.

In other words, the facility to backup window groups using firefox sync has been accomplished via bookmarks (which works around firefox sync data size limitations), ~but that currently is a manual process, i.e. one that allows you to backup existing window groups individually.~

Didn't I already do it?
screenshot_1
screenshot_2

Ah yes I didn't see that one! But how to import automatically from backup to new browser?

@GonzRon
default

Yes of course, I see that one. But I think this feature request is asking for automatic import from bookmark folders to groups. In other works automatic synchronization of window groups between browsers by using Firefox bookmarks to transfer the data.

Computer 1 --> Browser 1 --> STG Window Groups >>>> Automatic STG BookMarks Folder Backup
Computer 1 --> Browser 2 --> STG Window Groups <<<< Automatic STG BookMarks Folder Import

Automatic import is not yet possible due to technical reasons of the browser.

What about a one click loading of some specific backup file from the drop down menu?

The steps could be:

  • machine A: automatically create a backup named "machineA" (for instance) every hour (it already does that) in a shared folder (Dropbox, Syncthing or whatever the user has setup)
  • machine B: click the simple tab groups toolbar icon and hit the load icon in that menu (next to the "create new group" or something like that) and automatically import the new session from file (something that this extension already does)
  • machine B: automatically create a backup named "machineB" (for instance) every hour, allowing the same thing to be done on machine A when getting back to it

Automatically save the file is only possible in the download folder. And adding it to Dropbox is unlikely.

Any savvy user could do a symlink or a small script to copy that automatically to Dropbox/Syncthing/etc

I have a question about the backup to bookmark folder - it seems that when i close tabs from a tab group, they still remain in the backup and accumulate (i believe with a separator in between them). This might be the intended behavior for backups, but I tend to use this as a "sync" feature between browsers on different PCs. Therefore, it would be nice to have the option that the tabs are saved to the bookmarks "as is" - thereby replacing all the bookmarks in the previous backup. In other words, when i close a tab in the tab group, it will no longer appear in the backup, and this feature would operate as a true sync between browsers.

Is this possible as an option?

@lx0n2acl Yes, I thought to make this functionality customizable, but for some reason I didn’t)) in the near future I will make an option in the settings for the controllability of this behavior (bookmarks without tabs that are closed)

Automatic import is not yet possible due to technical reasons of the browser.

Hi Drive4ik, sorry if I reopen this old discussion.
I wonder if this could be of help, to create an auto sync from bookmarks functionality:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/bookmarks
From what I see there, it looks like it can be done. Am I missing something else?
Thanks.

I have been using Workona now. They just - finally - launched their plugin to Firefox. Works great so far, allows you to create groups much in the same manner as STG and automatically syncs across all your machines.

I had some sync problems with it on Chrome, but now on Firefox they are gone.

Hi @JackSlaterIV
Nothing to worry about

Bookmark sync already implemented
enable bookmark permission
изображение

and then you can change auto backup folder name
изображение

manually create backup of all groups
изображение

or any group of your choice
изображение

изображение

Then bookmarks will be synchronized between devices (if bookmark synchronization is enabled in the settings in the browser)

@Drive4ik
Thanks, but it does not automatically import from the bookmark folder, after the browser starts up.
Can you add this automatic import?
In one message above, you wrote that there was a technical issue in FF which blocked you from implementing this automatic import. Can you tell me more about it?

@JackSlaterIV
Bookmarks do not have attachment to FF containers, and are unlikely to have it. Therefore, you cannot restore the bookmark in the desired container.
Some users have 3000+ tabs, you can imagine how much synchronization will take.
Also, one of the main problems - the addon cannot know when FF has finished its synchronization (bookmarks, settings, passwords, etc. that you have chosen in the browser settings) and this can take a lot of time (5+ min) and it is difficult for the addon to understand when to start synchronization, and this is very important, because you need to have the most recent "snapshot" of data, but bookmarks do not have this ...
When the FF increases the capacity https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/sync at least to 10 MB, then I will start to think how to implement this.
It’s just what immediately comes to mind, there are more minor problems.
But so far this is not feasible.

@JackSlaterIV
Bookmarks do not have attachment to FF containers, and are unlikely to have it. Therefore, you cannot restore the bookmark in the desired container.
Some users have 3000+ tabs, you can imagine how much synchronization will take.
Also, one of the main problems - the addon cannot know when FF has finished its synchronization (bookmarks, settings, passwords, etc. that you have chosen in the browser settings) and this can take a lot of time (5+ min) and it is difficult for the addon to understand when to start synchronization, and this is very important, because you need to have the most recent "snapshot" of data, but bookmarks do not have this ...
When the FF increases the capacity https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/sync at least to 10 MB, then I will start to think how to implement this.
It’s just what immediately comes to mind, there are more minor problems.
But so far this is not feasible.

Hello @Drive4ik Thanks for the extension. Firefox will never have, and shouldn't have MB sync limits for the reasons you mentioned in terms of sync start-complete delays.

I do have a solution suggestion. A majority of the users are not having 3000+ tabs, and those who do should really look into using bookmarks, for the rest (and the majority of us) the following would work.

Apply simple lookup of current tab numbers and use firefox sync if they are under a safe margin (let's say 500). If they are above the safe margin, show a little alert on the top of the simple tab group window that says "Tabs Exceed Firefox Sync limits".

The sync issue is whats keeping me from adopting the plugin fully as others offer syncing. The groups really are most useful as a medium term management solution that is ideal for a desk to laptop workflow.

Let me know if I can help with UX suggestions, I am mostly a designer.

@Drive4ik
I don't know much about coding extensions, but couldn't it be possible to make a small text file with the URLs of someone's open tabs listed? This would solve the problem of file size. Also, rather than checking when Firefox is done with syncing all of the passwords, browser settings, etc., couldn't STG just check for updates to this file on its own, independent loop?

I'm also interested in this feature and I'd be willing to help implement it.

I currently have about 300 tabs in 21 groups and the latest save file in my downloads folder has 92.3kB. If I read the documentation correctly, an extension can save up to 100kB of data to Firefox Sync. That's obviously not sufficient if the data is stored in plain JSON, but I think it could be made to work: Compressing the file with gzip --best results in a file that's just 19.5kB. With brotli it's only 16.5kB. I don't think storage.sync can store binary data, so the data would have to be encoded somehow. Using base64 it's still only 26kB with gzip and 22kB with brotli. Assuming the number of tabs per kB can be extrapolated linearly, it'd be possible to store 1360 tabs with brotli + base64 in Firefox Sync.

Now, that might still not be enough for some people, but I feel it's not the majority and the extension could show an error in this case. Maybe an option to disable or only enable sync for some tab groups might be a possibility too.

Another option might be to think up some kind of binary format that's less verbose than JSON, although I'm not sure if that has a significant advantage over the compression approach while at the same time making debugging and adding new features a lot harder.

What do you think @Drive4ik ?

@maxkl there’s custom JSON encoders that can reduce the size dramatically (can’t remember the names right now)

@maxkl this is one of the ones I was thinking about: https://github.com/KilledByAPixel/JSONCrush although it’s URI-optimized, so maybe not _the best_ match.

Now, that might still not be enough for some people, but I feel it's not the majority and the extension could show an error in this case.

uBlock Origin for example shows the amount of sync data used in relation to the totally available space using a simple bar below the cloud buttons in the settings UI (sorry it's in German):

Bildschirmfoto von 2020-10-17 15-04-11

(The light grey bar is the total space; the dark grey bar is the used space; the purple bar is the space used by _my rules_ as a part of all synced settings.)

If FF sync support gets implemented for STG, it would be cool to indicate the fraction used of the total available space (100KiB) in the UI. So the user could reduce the number of open tabs some time ahead of running into the hard storage limit which would probably help reduce frustration when hitting the limit.

@maxkl this is one of the ones I was thinking about: https://github.com/KilledByAPixel/JSONCrush although it’s URI-optimized, so maybe not _the best_ match.

That's a nice find! I just tried it on my 90kB file, and the result is still 51kB big, probably because of the URI encoding. But another, similar content-aware compression algorithm might work nicely. I'll try to look into that some more...

Edit: I forgot to add that compressing the JSONCrushed file with brotli results in 18kB, so it's still bigger than just brotli without the intermediate step

@salim-b Thanks, I didn't know uBlock Origin had that feature until now. I agree that that's a nice way to implement it and it's similar to what I had in mind. Their wiki page has some more info: https://github.com/gorhill/uBlock/wiki/Cloud-storage

I managed to bring it down to 15.7kB (20.9kB in base64) by flattening the tab groups array and applying brotli compression afterwards. This is what it looks in the JSON file:

"groups": [
    {
        "id": 1,
        "title": "FPGA",
        "iconColor": "hsla(277, 100%, 50%, 1)",
        "iconUrl": null,
        "iconViewType": "old-tab-groups",
        "tabs": [
            {
                "url": "https://reference.digilentinc.com/reference/programmable-logic/arty-z7/reference-manual",
                "title": "Arty Z7 Reference Manual [Digilent Documentation]"
            },
            {
                "url": "https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/wp/wp-01082-quartus-ii-metastability.pdf",
                "title": "Understanding Metastability in FPGAs - wp-01082-quartus-ii-metastability.pdf"
            },
            ...
        ],
        "catchTabRules": "",
        "catchTabContainers": [],
        "isSticky": false,
        "muteTabsWhenGroupCloseAndRestoreWhenOpen": false,
        "showTabAfterMovingItIntoThisGroup": false,
        "dontDiscardTabsAfterHideThisGroup": false,
        "newTabContainer": "firefox-default",
        "isArchive": false,
        "isMain": false,
        "moveToMainIfNotInCatchTabRules": false,
        "ifDifferentContainerReOpen": false,
        "excludeContainersForReOpen": []
    },
    ...
]

And it's converted to this by the flattening step:

"groups": [
    [
        1,
        "FPGA",
        "hsla(277, 100%, 50%, 1)",
        null,
        "old-tab-groups",
        "",
        [],
        false,
        false,
        false,
        false,
        "firefox-default",
        false,
        false,
        false,
        false,
        [],
        "https://reference.digilentinc.com/reference/programmable-logic/arty-z7/reference-manual",
        "Arty Z7 Reference Manual [Digilent Documentation]",
        "https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/wp/wp-01082-quartus-ii-metastability.pdf",
        "Understanding Metastability in FPGAs - wp-01082-quartus-ii-metastability.pdf",
        ...
    ],
    ...
]

All the other things I tried did not reduce the size after compression – gzip and brotli are dealing with common substrings really effectively after all... It might be possible to shave another kB off by also applying this flattening step to the top-level properties but I'm not sure if that's worth it because it's just a constant overhead.

Honestly, I'm not even sure if the flattening step makes sense on the tab group array. It's just a 5% improvement and would require the decompressor to be aware of the format version because the keys might change.

Let me know what you think

The first what should be done is to store the favIconUrl and own group icon urls into a separate file to use this only locally. The file size was here reduced from 230KB to 8KB without these details. For syncing groups and tabs between devices there are no favicon url data required. This could be synced locally from webpage if the tab will be reloaded.

Maybe we can save tab details with bookmarks, and only save groups and tab(bookmark) ids in the data file. It will reduce the size of the file to sync significantly.

The main problem is that we have no access to already cached favicon data in Firefox. If this bug 1315616 would be fixed (this is open already 4 years) then we could use the local stored data of Firefox self. Until this is fixed the data should be stored and ex/imported in a separate file to updata STG Favicon URL Database manually between different clients or its required to reload the webpage.

The first what should be done is to store the favIconUrl and own group icon urls into a separate file to use this only locally. The file size was here reduced from 230KB to 8KB without these details. For syncing groups and tabs between devices there are no favicon url data required. This could be synced locally from webpage if the tab will be reloaded.

Ah yes, I forgot to mention that I have already disabled backing up of favicons. I agree that they should not be synced

I'm trying to set up sync, but the extension seems to handle conflicts by just duplicating everything.

image

Is there a setting I'm missing that addresses this? Or some procedure to do or not do?

Looking back through this discussion, I think maybe I just misunderstood what was actually implemented. Seems like the automatic bookmarks sync behaves like firefox's own "tabs on other devices", which is the paradigm I'm trying to escape.

However I think it would be simple to get a workable solution: a button that overwrites the current session with what is in bookmarks.

It's not elegant, and would require the user manually:

  • Export all groups to bookmarks & manually trigger firefox sync before leaving PC.
  • Manually trigger firefox sync & import all groups from bookmarks, overwriting all local changes before using firefox.

And probably disable automatic bookmark backup so there's no chance of an accident.

Far from ideal but it'd be worth having, @Drive4ik , what do you think?

Edit: It'd probably be wise to have the backend logic only act on _differences_: instead of telling firefox to close all tabs and reopen all tabs, just close tabs that don't exist anymore and open new tabs as appropriate.


Oh, and I'm not concerned with syncing containers. Every container related extension for firefox has users clamoring for container syncing and it's clearly just not possible right now. It can't be done, best to just ignore it.

(As an aside, you can transport container rules between computers with this extension- it's just about the only way to do it)
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mzelyony picture mzelyony  Â·  6Comments

ddTech picture ddTech  Â·  4Comments

EstherMoellman picture EstherMoellman  Â·  4Comments

ajvsol picture ajvsol  Â·  6Comments

kstev99 picture kstev99  Â·  4Comments