How to sync chrome extension options

蓝咒 提交于 2019-12-20 08:41:12

问题


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?


回答1:


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!




回答2:


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!




回答3:


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




回答4:


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:


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.



来源:https://stackoverflow.com/questions/4213882/how-to-sync-chrome-extension-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!