How to sync chrome extension options

2019-03-08 14:07发布

I've made a Chrome extension with an options page. The data is saved in localstorage and works just fine.

Chrome doesn't sync the localstorage to the cloud, just the extensions. This means that any user data will not sync to other computers of the same google account.

I can not find an API at http://developer.chrome.com/extensions/docs.html which allows me to sync the user-chosen preferences.

What methods do you suggest?

5条回答
可以哭但决不认输i
2楼-- · 2019-03-08 14:50

You should be able to use HTML5 WebDatabases, but you cannot. See comments below.

查看更多
我只想做你的唯一
3楼-- · 2019-03-08 14:52

Nathan Moos told you truth :) But you don't need to write it by oneself, you can use Ankit Ahuja solution from Sylebot extension. You will need file js/sync.js. Source code is great, and it works great!

查看更多
Anthone
4楼-- · 2019-03-08 14:55

You could serialize some of the options to a bookmark and tell the user to enable bookmark sync. Then, you could read from the bookmark or build a pseudo-"localStorage" object around the bookmark.

查看更多
祖国的老花朵
5楼-- · 2019-03-08 14:56

You could try to do it with Google Docs like Chrome does with bookmarks. I don't know how far the api reaches but this seems a rather basic operation.

查看更多
萌系小妹纸
6楼-- · 2019-03-08 14:57

In the (hopefully near) future, you'll be You are now able to store stuff in chrome.storage.sync, and it will be synced automagically.

Unless you need something right now, do consider putting all your configurations in an single object, sometime later you'll be able to just sync it!

Edit: now this is available in stable Chrome!

查看更多
登录 后发表回答