google-chrome-storage

Saving files in a Chrome App

一曲冷凌霜 提交于 2019-12-14 02:38:29
问题 Summary Normally I could download a bunch of files, but Chrome Apps won't show the download shelf when a download occurs. What would be the best way of getting around this limitation of Chrome Apps? Ideas I could go about this by creating a zip file, but this would require the user to perform an extra step of unzipping the file. I'm able to silently download the files, and so I could display a prompt to the user when the file is downloaded, but this would require the user to manually search

How to push multiple values to a chrome.storage.local array key?

核能气质少年 提交于 2019-12-12 14:24:13
问题 I'm using the following code to set a key:value to the local storage: chrome.storage.local.set({"key": value}, null); What can I do to add multiple values to the key "key"? 回答1: First use the get method and then use set inside the get callback to add your new storage data as a key/value pair to the storage object returned from get . Example: chrome.storage.local.get(function(cfg) { if(typeof(cfg["key"]) !== 'undefined' && cfg["key"] instanceof Array) { cfg["key"].push("value"); } else { cfg[

Chrome Extension: Background page interval runs, but sees no jQuery plugin

北慕城南 提交于 2019-12-12 03:57:22
问题 I am creating a chrome extension that has background, which runs every second and updates chrome.storage... and it is called artistSetter.js . Here it is: chrome.storage.local.get(function(items){ $.each($('#supplySong > a > span.sidebar-heading'), function(){ if ($(this).css('background-color') == 'rgb(22, 156, 217)'){ chrome.storage.local.set({"currentArtist": $(this)[0].innerText}); } }); }); Background page is this: setInterval(function () { chrome.tabs.executeScript(null, {file: 'js

Affect a variable in callback function

陌路散爱 提交于 2019-12-11 06:44:28
问题 This kind of question is very frequent, but I could not make what I want. My code look like this. Some pubKeyProfiles are stored in chrome.storage, and I want my function getProfile to return one of them. getProfile(keyPairId){ var profile = null; chrome.storage.local.get({ pubKeyProfiles : [] }, function (result) { var pubKeyProfiles = result.pubKeyProfiles; for (var i = 0; i < pubKeyProfiles.length; ++i) { if(pubKeyProfiles[i].pubKey.keyId === keyPairId){ profile = pubKeyProfiles[i]; } } })

Uncaught TypeError: Cannot read property 'local' of undefined in chrome extension

一笑奈何 提交于 2019-12-10 03:21:18
问题 I have written a Chrome extension. I cannot use localStorage.setItem and localStorage.getItem for storing and retrieving because background and browser action runs in different environment [as seen here]. So I decided to use the Chrome storage API: var storage = chrome.storage.local; var myTestVar = 'somevar'; var obj = {}; obj[myTestVar] = $("#somevar").val(); storage.set(obj); which produced the following error: Uncaught TypeError: Cannot read property 'local' of undefined What am I doing

HTML5 sessionStorage or chrome.storage for Chrome Extension?

余生颓废 提交于 2019-12-08 08:01:39
问题 I have a Chrome Extension that is only a content script. I want to persist some data that is calculated in the content script so I can easily access it while browsing without having to recalculate it on each page. I only need the data to be stored for the session. I was looking at the chrome.storage API but it seems data will persist there past the session. I have previous experience using HTML5 sessionStorage, but I feel like I should be leveraging Google's API here. Any input is appreciated

chrome.storage.sync.remove array doesn't work

五迷三道 提交于 2019-12-03 16:24:33
I am making a small Chrome extension. I would like to use chrome.storage but I can't get it to delete multiple items (array) from storage. Single item removal works. function clearNotes(symbol) { var toRemove = "{"; chrome.storage.sync.get(function(Items) { $.each(Items, function(index, value) { toRemove += "'" + index + "',"; }); if (toRemove.charAt(toRemove.length - 1) == ",") { toRemove = toRemove.slice(0,- 1); } toRemove = "}"; alert(toRemove); }); chrome.storage.sync.remove(toRemove, function(Items) { alert("removed"); chrome.storage.sync.get( function(Items) { $.each(Items, function

chrome.storage set\\get clarification

元气小坏坏 提交于 2019-12-01 05:11:59
I want to save information in my extenstion. I use Chrome.storage.sync to do that, however when I read right after saving I am unable to rightly retrieve the value. Probably doing something stupid.... I tried clearing the local storage with chrome.storage.sync.clear but that did not help. My save function is (looked at how Currently did it): save: function (type, key, data) { Storage.storageOption(type).set({key:data}, function () { console.log("saved data"); }); load: function (type, key) { Storage.storageOption(type).get(key, function (object) { console.log("read : " +object); return object

chrome.storage set\get clarification

假装没事ソ 提交于 2019-12-01 02:44:54
问题 I want to save information in my extenstion. I use Chrome.storage.sync to do that, however when I read right after saving I am unable to rightly retrieve the value. Probably doing something stupid.... I tried clearing the local storage with chrome.storage.sync.clear but that did not help. My save function is (looked at how Currently did it): save: function (type, key, data) { Storage.storageOption(type).set({key:data}, function () { console.log("saved data"); }); load: function (type, key) {

Get all keys from Chrome Storage

我的未来我决定 提交于 2019-11-30 04:26:26
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? Rob W 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. For some example code: chrome.storage.sync.get(null, function(items) { var allKeys = Object.keys(items); console.log(allKeys); }); 来源: https://stackoverflow.com/questions/18150774/get-all-keys-from-chrome-storage