javascript Chrome 扩展程序,存储数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16092932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 03:14:28  来源:igfitidea点击:

Chrome extension, Store data

javascriptgoogle-chromegoogle-chrome-extension

提问by Siamak A.Motlagh

I've read this question: Chrome Extensions & Javasctipy Databasebut I want an answer with more details and more clear.

我读过这个问题:Chrome 扩展和 Javasctipy 数据库,但我想要一个更详细、更清晰的答案。

How can I store some of my extension settings?

如何存储我的一些扩展设置?

Is it possible to use a database to do such things with JavaScript?

是否可以使用数据库用 JavaScript 来做这样的事情?

Is there any good tutorial on it?

有什么好的教程吗?

I don't want to use Local Storage, because I do notwant the behavior of SESSIONS

我不想使用本地存储,因为我想要 SESSIONS 的行为

Thanks.

谢谢。

回答by T.J. Crowder

You could use chrome.storage.syncor chrome.storage.local(docs). Both are local storage (not session storage); synchas the additional advantage that it syncs to the user's Google account if they've connected Chrome to it.

您可以使用chrome.storage.syncchrome.storage.local文档)。两者都是本地存储(不是会话存储);sync如果用户已将 Chrome 连接到它,它还有一个额外的优势,它会同步到用户的 Google 帐户。

回答by duckbrain

The following page lists the storage mechanisms in HTML5. WebSQL gives you a pretty good database for your javascript to use.

以下页面列出了 HTML5 中的存储机制。WebSQL 为您的 javascript 提供了一个非常好的数据库。

http://www.html5rocks.com/en/features/storage

http://www.html5rocks.com/en/features/storage

UPDATE: It has been some time since I posted this. WebSQL has been dropped. Browsers will probably still continue to support it, but all the implementations have been SQLite. IndexedDB is the way to go now. I have used it and it is a little hard to get into, but works well for a client side database.

更新:我发布这个已经有一段时间了。WebSQL 已被删除。浏览器可能仍会继续支持它,但所有的实现都是 SQLite。IndexedDB 是现在要走的路。我已经使用过它,它有点难以进入,但对于客户端数据库来说效果很好。

UPDATE AGAIN: Chrome changing things. See T.J. Crowder's Answer.

再次更新:Chrome 正在改变事物。参见TJ Crowder 的回答

回答by wh1t30ps

I believe this is a simple solution for you if you just want to save some settings. It also has some examples, hope it helps.

如果您只想保存一些设置,我相信这对您来说是一个简单的解决方案。还有一些例子,希望能帮到你。

https://developer.chrome.com/extensions/storage.html

https://developer.chrome.com/extensions/storage.html