问题标签 [google-chrome-storage]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - 谷歌浏览器扩展如何检查存储是否为空?
如何检查我的谷歌浏览器扩展中的存储是否为空?我尝试了很多可能性,但对我没有任何效果。
javascript - 重启电脑会清除Chrome.Storage.Local中的数据吗?
我使用 Chrome.Storage.Local 来保存我的 chrome 扩展的一些数据。但是我发现重启电脑后数据就没了。这是这个api的特点吗?我想知道 Chrome.Storage.Local 中存储的数据的生命周期。谢谢。
javascript - 函数未访问扩展中的 Chrome 存储值
我正在开发一个 chrome 扩展程序,它将给定页面上的 pries 转换为用户赚取该金额所需的工作时间。该扩展通过弹出窗口接收用户工资信息,然后将其设置在 chrome 存储中。那部分工作正常。
我遇到的问题是访问该值并使用它来运行计算。JS 很好地解析了这些值并调用了转换函数,但在计算中只使用占位符每小时值 1,而不是从 chrome 存储中检索它。相反,它似乎在所有解析之后访问了 chrome 存储(我根据控制台日志的运行时间来计算)。
你知道是什么原因造成的吗?我已经尝试将整个解析移动到它自己的函数中,以便在 $(document).ready(function) 的末尾调用,但它仍然不会从 chrome 存储中获取值。
在 content.js 中:
javascript - How to use chrome.storage along with a remotely hosted database for a chrome extension?
I am working on a chrome extension which has to store data of its user. For that I am using a hosted server which is running a mysql database. But currently any addition or change in data fires a request to the hosted server.
Chrome extension provides chrome.storage.local
API which is suitable to store data upto 5mb. I want to take advantage of this storage API to reduce number of requests to my hosted server by using it as a temporary storage.
I am planning to use chrome.storage.onChanged.addListener
and chrome.storage.local.getBytesInUse
to check if data stored crosses a certain threshold value and then only fire an ajax request to the remote server to save the data. Upon successful response, the old data in chrome.storage will be flushed off.
But there are chances of losing some new data which is created during the process of request/response cycle from the server.
How can I prevent any loss of data? Is there any alternative solution to this optimization problem of reducing number of requests to the remote server from the extension?
Thanks.
javascript - 我们可以将文件存储在 Chrome 存储中,而不是字符串
我可以在Chrome 存储 API页面中读到,我们可以在 Chrome 存储中针对键存储字符串值。有什么方法可以根据 Chrome 存储中的密钥存储文件吗?
javascript - Chrome 扩展存储 api 无法保存价值
我正在尝试进行私人扩展,我需要保存一个布尔值。我目前正在使用 chrome storage api 来执行此操作,但我无法在内容脚本中获取值。当我将值记录到控制台时,它是正确的,但是当我将它保存到变量时,它是未定义的。
我努力了
我试图只返回值
有谁知道我做错了什么?
javascript - if() 语句中 chrome.storage.sync.get 的返回 return undifinde
我在本地存储中保存了一个状态并尝试在 if 语句中使用它
如何解决这个问题
我正在尝试启用或禁用内容脚本中的部分代码
javascript - Chrome 扩展:如何使用 javascript 从导入的 .json 文件中提取变量值对?
我正在编写一个 chrome 扩展,我正在从选项页面导出和导入一个 json 文件。
这将正确存储为文件。例子:
{"colorBg":"#ffffff","colorBtn":"#000000","colorDrop":"#666666","colorFg":"#333333","colorHi":"#cc0000","colorLi": "#000000","colorLi2":"#000000"}
但是我找不到将 .json 文件重新导入的 chrome api。我在 stackoverflow 上进行了搜索,发现了这个——https://stackoverflow.com/a/38838572/8116516 ,它正在工作。
导入成功,我可以在控制台中查看列表,但我不知道如何从这个 json 对象将值返回到我的 chrome 存储中。有为此的chrome api吗?如何提取变量和十六进制颜色值以在现有的 chrome 存储中设置它们?
如果我应该提供更多信息或代码,请告诉我。该项目非常大,我不确定有什么帮助。我对这一切都比较陌生。
google-chrome - Chrome.storage.sync.get() 似乎在复制密钥?
我正在使用以下顺序保存一些设置
在setLocalSettings
函数定义之后的行,“设置”对象注销为
{"email_format":"individual","close_tab":true,"frequency":"DAILY"}
(按预期正确)。当我使用此序列获取设置时:
LMLSettingsContainer
注销为
访问我的设置LMLSettingsContainer.LML_Settings["<setting>"]
有点烦人(这也是我将顶部变量命名为 LMLSettingsContainer 的全部原因)。
有谁知道是否有办法让 chrome 保存/解开这些值?