This is a chrome extension and there are 2 scripts involved 1st is for the settings page(default_popup) and the second is for actions with a certain webpage. All is fine in the settings page but when i try to access data in the second script i get nothing. Any pointers would be appreciated! Will add code on request, just tell me what you want to see.
[manifest]
{
"name" : "TEST",
"description" : "it just works",
"version" : "1.0",
"manifest_version" : 2,
"permissions": [
"activeTab",
"declarativeContent",
"storage"
],
"content_scripts": [
{
"matches": [This is filled in the original],
"js": ["jquery.js", "script.js"]
}
],
"browser_action":{
"default_popup": "popup.html"
}
}
[input.js]
$(function(){
window.onload = function() {
updateval();
document.getElementById('save').onclick = function(){
var value1 = document.getElementById('input_refresh').value;
var value2 = document.getElementById('input_max').value;
var value3 = document.getElementById('input_min').value;
var value4 = document.getElementById('input_disc').value;
//alert(value);
chrome.storage.local.set({
'ref' : value1,
'max' : value2,
'min' : value3,
'disc' : value4
}, function(){
console.log('Values saved');
$("#save").val("Saved!");
setTimeout(function() {
$("#save").val("Save Settings");
}, 2000);
});
}
document.getElementById('reset').onclick = function(){
chrome.storage.local.set({
'ref' : 10,
'max' : 999999,
'min' : 0,
'disc' : 30
}, function(){
updateval();
console.log('Values got reset');
$("#reset").val("Reset!");
setTimeout(function() {
$("#reset").val("Reset To Default");
}, 2000);
});
}
}
function updateval (){
chrome.storage.local.get([
'ref',
'max',
'min',
'disc'
], function(data){
$('#input_refresh').val(data.ref);
$('#input_max').val(data.max);
$('#input_min').val(data.min);
$('#input_disc').val(data.disc);
console.log('Values Gotten');
});
}
})();
[script.js]
$(document).ready(function(){
chrome.storage.local.get([
'ref',
'max',
'min',
'disc'
], function(data){
var ref = data.ref;
var max = data.max;
var min = data.min;
var disc = data.disc;
console.log('Values Gotten');
});
if(window.location.href.indexOf("") > -1) {
//console.log("homepage");
main();
}
});
function main() { additional code here}