Answer the question
In order to leave comments, you need to log in
Why don't all scripts in chrome extension get data from localstorage?
I'm writing an extension for myself. We need to store some data in localstorage. There are scripts that work with the content of the page and scripts that are responsible for the pop-up window (when clicking on the extension icon) and write data to localstorage.
So, I write data to localstorage and try to access the storage through scripts responsible for the content, but instead of values they get just null, although everything is done within the framework of one extension and its scripts. Don't tell me what happened?
Here is the manifest:
{
"content_scripts": [ {
"persistent": true,
"js": [ "jquery.js", "background.js", "inject.js" ],
"matches": [ "http://*/*", "https://*/*" ],
"run_at": "document_end"
} ],
"description": "Описание",
"homepage_url": "http://example.com",
"icons": {
"128": "128.png"
},
"background": {
"persistent": true,
"scripts": ["jquery.js", "background.js"]
},
"manifest_version": 2,
"name": "ADMINEX",
"permissions": [ "background", "storage", "tabs", "alarms", "http://*/*", "https://*/*" ],
"version": "1.1",
"browser_action": {
"default_title": "EXTNAME",
"default_icon": "128.png",
"default_popup": "popup.html"
},
}
localStorage.setItem('iswork', '1'); //запись
localStorage.getItem('iswork'); // получение
Answer the question
In order to leave comments, you need to log in
localStorage can be disabled, or automatically erased if you are in incognito browser mode. Maybe it?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question