如何同步不同计算机上的Chrome扩展程序数据? [英] How to synchronize Chrome extension data on different computers?

查看:324
本文介绍了如何同步不同计算机上的Chrome扩展程序数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户维护链接列表的扩展。将这些数据在计算机之间进行同步(在工作和家中)会很好。什么是可能的解决方案?



Chrome有扩展同步选项,但我不确定它是否同步数据(如果是的话,我会感到惊讶)。即使如此,也不是每个人都希望所有其他扩展程序都被同步。



我可以将链接存储在特定的书签文件夹中,并使用内置的书签同步功能,但在这种情况下,所有的书签都会同步(不是所有用户都会想要这样做)。



我可以使用任何外部网站?一些容易使用和链接到谷歌账户?

(我不想为此建立自己的网站)

:从Chrome 20及更高版本开始,您可以使用

 扩展/ storage.htmlrel =noreferrer> chrome.storage 模块保存到云中。 chrome.experimental.storage.sync.set({'settingAlwaysOn':true},function(){
console.log('云中保存的选项');
});






在Chrome 20之前

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



由于您排除了书签的使用,如果用户不希望书签同步。每次通过存储(Web SQL Storage,localStorage,IndexDB)持久保存数据时,您将抓取该对象并将其序列化为JSON(通过JSON.stringify),然后您将它发送给一些在线服务,如Google Docs。



对于Web SQL Storage和IndexDB来说,这将非常棘手,您必须自己做进口商和出口商。对于localStorage来说,它非常简单,因为它是一个键/值对。



需要一些工作将它链接到Google帐户(例如 Docs ),您将不得不使用OAuth并执行管道连接您的扩展到服务。一旦连接起来,维护状态并不难。

祝你好运:)

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)

解决方案

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

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

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