google-chrome-storage

Using a variable key in chrome.storage.local.set [duplicate]

天大地大妈咪最大 提交于 2019-11-29 08:02:32
This question already has an answer here: chrome.storage.local.set using a variable key name 2 answers I am creating a chrome-extension. I don't know how to use a variable as the key to chrome.storage.local.set() function. I have tried var key = 'myKey'; chrome.storage.local.get(key, function(val) { chrome.storage.local.set({key:val[key]+param1}); //appending param1 alert(val[key]); } Here i am trying to get the value of val[key] and append a string param1 and place it back to the storage using the same key. But I am not able to do so. the alert box displays undefined all the time. But when I

Get all keys from Chrome Storage

北城以北 提交于 2019-11-29 01:40:13
问题 I can get the value of a storage key with the Chrome Extension API: chrome.storage.sync.get("someKey", function() {}); How can I get all key names that exist in the Chrome storage? 回答1: From the documentation (emphasis mine): An empty list or object will return an empty result object. Pass in null to get the entire contents of storage. Don't forget to change "storage.sync" to storage.local if you're using local storage. For some example code: chrome.storage.sync.get(null, function(items) {

Chrome extension store large amounts of data

北城余情 提交于 2019-11-28 14:04:03
I'm looking for an efficient way to store large amounts of data in my chrome extension. I've got a few txt files which are around 1-2mb. I'd like my chrome extension to 'cache' them locally so I don't need to fetch them every time. I've found syncFileSystem but this is only available for packed apps. There were warnings when trying to install this extension: 'syncFileSystem' is only allowed for packaged apps, but this is a extension. What is the best way to store this sort of data in a chrome extension? manifest.json { "manifest_version": 2, "name": "__MSG_name__", "version": "1.0", "default

how to remove data from a object using chrome storage?

前提是你 提交于 2019-11-28 13:56:20
i have an object stored inside chrome storage that looks like this: { "planA": { 123: {key: 'some key'} 124: {key: 'some other key'} }, "planB": { 223: {key: 'some key'} 234: {key: 'some other key'} } } i want to do something like chrome.storage.sync.remove([{"planA": "123"}]); but that seems not to work Error in response to storage.get: Error: Invalid value for argument 1. Value does not match any valid type choices. from the documentation StorageArea.remove(string or array of string keys, function callback) ant ideas? You can't do that in a single API call. The API only gives access to top

chrome.storage.sync undefined?

最后都变了- 提交于 2019-11-27 19:36:49
I'm trying to use chrome storage in an extension, via a content_script, but I keep failing on Uncaught TypeError: Cannot read property 'sync' of undefined This is my code: testChromeStorage(); function testChromeStorage() { console.log("Saving"); chrome.storage.sync.set({'value': theValue}, function() { message('Settings saved'); }); chrome.storage.sync.get("value", function (retVal) { console.log("Got it? " + retVal.value); }); } You have to add the "storage" permission in your manifest.json file, i.e.: ... "permissions": [ "storage" ], ... For more information, see: https://developer.chrome

Chrome extension store large amounts of data

馋奶兔 提交于 2019-11-27 08:11:12
问题 I'm looking for an efficient way to store large amounts of data in my chrome extension. I've got a few txt files which are around 1-2mb. I'd like my chrome extension to 'cache' them locally so I don't need to fetch them every time. I've found syncFileSystem but this is only available for packed apps. There were warnings when trying to install this extension: 'syncFileSystem' is only allowed for packaged apps, but this is a extension. What is the best way to store this sort of data in a chrome

how to remove data from a object using chrome storage?

非 Y 不嫁゛ 提交于 2019-11-27 08:01:46
问题 i have an object stored inside chrome storage that looks like this: { "planA": { 123: {key: 'some key'} 124: {key: 'some other key'} }, "planB": { 223: {key: 'some key'} 234: {key: 'some other key'} } } i want to do something like chrome.storage.sync.remove([{"planA": "123"}]); but that seems not to work Error in response to storage.get: Error: Invalid value for argument 1. Value does not match any valid type choices. from the documentation StorageArea.remove(string or array of string keys,

Inspect chrome.storage.sync while debugging Chrome extension

久未见 提交于 2019-11-27 05:29:29
Chrome DevTools has a handy inspector for Local Storage and Session Storage, but is there nothing to inspect chrome.storage.sync ? chrome://sync-internals/ doesn't seem to display the actual contents of the synchronized storage per extension. Storage Area Explorer extension provides a UI for viewing, editing, clearing, importing and exporting of chrome.storage.local , chrome.storage.sync , localStorage and sessionStorage : A poor workaround is to call get and obtain all the stored values. Of course, this doesn't let you conveniently edit them: chrome.storage.sync.get(null, function callback

Returning Chrome storage API value without function

天涯浪子 提交于 2019-11-27 04:25:54
For the past two days I have been working with chrome asynchronous storage. It works "fine" if you have a function. (Like Below): chrome.storage.sync.get({"disableautoplay": true}, function(e){ console.log(e.disableautoplay); }); My problem is that I can't use a function with what I'm doing. I want to just return it, like LocalStorage can. Something like: var a = chrome.storage.sync.get({"disableautoplay": true}); or var a = chrome.storage.sync.get({"disableautoplay": true}, function(e){ return e.disableautoplay; }); I've tried a million combinations, even setting a public variable and setting

chrome.storage.sync undefined?

浪尽此生 提交于 2019-11-26 22:51:00
问题 I'm trying to use chrome storage in an extension, via a content_script, but I keep failing on Uncaught TypeError: Cannot read property 'sync' of undefined This is my code: testChromeStorage(); function testChromeStorage() { console.log("Saving"); chrome.storage.sync.set({'value': theValue}, function() { message('Settings saved'); }); chrome.storage.sync.get("value", function (retVal) { console.log("Got it? " + retVal.value); }); } 回答1: You have to add the "storage" permission in your manifest