如何同步不同电脑上的 Chrome 扩展数据? [英] How to synchronize Chrome extension data on different computers?

查看:63
本文介绍了如何同步不同电脑上的 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 有扩展同步选项,但我不确定它是否同步数据(如果是,我会感到惊讶).即使是这样,也不是每个人都希望他们的所有其他扩展都被同步.

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).

我可以使用任何外部网站吗?易于使用且与 Google 帐户相关联的东西?

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)

推荐答案

编辑:从 Chrome 20 及更高版本开始,您可以使用 chrome.storage 模块保存到云端.

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');
});

<小时>

Chrome 20 之前

您说得对,Chrome 同步扩展选项(在设置中)不会同步扩展数据.同步这些数据的唯一方法是通过第三方.

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.

每次通过存储(Web SQL 存储、localStorage、IndexDB)持久化数据时,您都会抓取该对象,并将其序列化为 JSON(通过 JSON.stringify),然后将其发送到某些在线服务,例如 Google Docs.

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.

这对于 Web SQL 存储和 IndexDB 来说是相当棘手的,您必须自己做导入器和导出器.对于 localStorage,它非常简单,因为它是一个键/值对.

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.

需要一些工作才能将其链接到 Google 帐户(例如 Docs) 您必须使用 OAuth 并进行管道连接以将您的扩展程序连接到服务.连接后,保持状态并不难.

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.

祝你好运:)

这篇关于如何同步不同电脑上的 Chrome 扩展数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆