我如何存储值在数组和重用它在chrome扩展存储的每一个会话
How can I store values in an array and reuse it every session in chrome extension storage?
我试图使一个数组与id(用户)的用户点击。函数是:
$('button').click(function(){
var value = $('this').parents('.username').attr('id')
// How to create array in the chrome storage?
// How can I push the value to an array and create a permanent one?
})
您可以尝试这样做:
chrome.storage.local.get("myArray", function(dataStored) { //load your saved array, if it exists
var workingArray = dataStored.myArray || []; //if it doesn't exist, create an empty one
workingArray.push(value); //add the value just obtained
chrome.storage.local.set({myArray:workingArray}); //save the array.
});
相关文章:
- 如何在chrome扩展中存储数据/结果,以及如何使用setTimeout使其只被调用一次
- Chrome存储API无法使用内容脚本
- 有没有一种方法可以从chrome'的存储映像
- Chrome,Safari在从本地存储读取时挂起,而Firefox很好
- 如何使用 Chrome 存储空间从对象中移除数据
- Chrome/Tampermonkey 用户脚本存储在文件系统上的什么位置
- 为内容脚本[Chrome扩展]获取本地存储价值的简单方法
- 将客户端生成的密码短语存储在chrome.storage.local中的安全含义
- 将对象设置为Chrome存储
- 在 Java 中使用 IE/Chrome HTML 渲染器或使用 JavaScript 存储文件
- Chrome 扩展程序无法访问数据存储
- 将上传的图像保存到本地存储(chrome 扩展程序)
- Chrome扩展程序:将数据存储在后台
- 在 chrome.storage 中正确存储对象
- Chrome 扩展程序是否可以利用客户端存储空间
- Chrome扩展程序:在后台提取数据并存储在数据库中
- 使用 iframe 的跨域本地存储 (Chrome)
- 阅读,存储chrome开发工具网络数据
- 存储数据在本地存储chrome扩展
- 存储chrome扩展选项没有关闭选项模式