How to synchronize Chrome extension data on different computers?

只愿长相守 提交于 2019-12-30 00:25:07

问题


I have an extension where users maintain a list of links. It would be nice to have this data synchronized between computers (at work and at home). What are the possible solutions?

Chrome has extension synchronization option but I am not sure if it synchronizes data or not (I would be surprised if yes). Even if it does, not everyone would want all their other extensions be synced.

I can store my links in a special bookmark folder and use built-in bookmark synchronization, but in this case all bookmarks would be synchronized too (not all users would want that either I think).

Any external sites I can use? Something easy to use and linked to a google account?

(I don't want to build my own site for this)


回答1:


Edit: As of Chrome 20 and above you can use chrome.storage module to save to the cloud.

chrome.experimental.storage.sync.set({'settingAlwaysOn': true}, function() {
  console.log('Saved option in the cloud');
});

Before Chrome 20

You're right, the Chrome Sync for extensions options (in settings) does not synchronize extension data. The only way to synchronize those data is through a third party.

Since you ruled out the usage of Bookmarks, which makes sense if users don't want bookmarks to be synchronized.

Everytime you persist data through storage (Web SQL Storage, localStorage, IndexDB), you grab that object, and serialize it into JSON (via JSON.stringify), and you send it to some online service such as Google Docs.

That would be quite tricky for Web SQL Storage and IndexDB, you would have to do your own importer and exporter. For localStorage it is pretty simple, since its a key/value pair.

It requires some work to link it to a Google Account (such as Docs) you would have to use OAuth and do the plumbing to connect your extension to the service. Once your connected, it is not that difficult to maintain the state.

Good luck :)




回答2:


Chrome 20 supports chrome.storage.sync API. It seems to fit your requirements perfectly.



来源:https://stackoverflow.com/questions/4901024/how-to-synchronize-chrome-extension-data-on-different-computers

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