如何在不同电脑上同步Chrome扩展程序数据?
我有一个扩展,用户可以在其中维护链接列表。如果能够在计算机(工作场所和家里)之间同步这些数据,那就太好了。可能的解决方案有哪些?
Chrome 有扩展同步选项,但我不确定它是否同步数据(如果是的话我会感到惊讶)。即使是这样,也不是每个人都希望同步所有其他扩展。
我可以将链接存储在特殊的书签文件夹中并使用内置书签同步,但在这种情况下,所有书签也会同步(我认为并非所有用户都希望如此)。
我可以使用任何外部网站吗?有一些易于使用并链接到谷歌帐户的东西吗?
(我不想为此建立自己的网站)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:从 Chrome 20 及更高版本开始,您可以使用 chrome.storage 模块保存到云端。
Chrome 20 之前
您是对的,Chrome 扩展程序同步选项(位于设置中)不会同步扩展程序数据。同步这些数据的唯一方法是通过第三方。
由于您排除了书签的使用,如果用户不希望同步书签,这是有道理的。
每次通过存储(Web SQL 存储、localStorage、IndexDB)保存数据时,您都会获取该对象,并将其序列化为 JSON(通过 JSON.stringify),然后将其发送到某些在线服务,例如 Google Docs。
这对于 Web SQL Storage 和 IndexDB 来说非常棘手,您必须自己创建导入器和导出器。对于 localStorage 来说它非常简单,因为它是一个键/值对。
需要做一些工作才能将其链接到 Google 帐户(例如Docs )您必须使用 OAuth 并进行管道连接以将您的扩展连接到服务。一旦连接成功,维护状态就不那么困难了。
祝你好运 :)
Edit: As of Chrome 20 and above you can use chrome.storage module to save to 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 :)
Chrome 20 支持 chrome.storage.sync API。它似乎完全符合您的要求。
Chrome 20 supports chrome.storage.sync API. It seems to fit your requirements perfectly.