In the "options.html" file I know exactly how to make a markup work to enable some javascript set like ...
<label>
<input type="checkbox" id="test">
Habilitar
</label>
That will execute the following codes inside options.js:
var test = document.getElementById('test').checked;
test: test
test: false
document.getElementById('test').checked = items.test;
Then the final result will be activated within an exemple.js:
var storage = chrome.storage.sync;
var info = 0;
var total_requests = 0;
var processed_requests = 0;
var cookie = document.cookie;
storage.get(function(settings) {
if (settings.test === undefined) {
settings.test = false;
storage.set({'test': settings.test});
}
if (settings.test) {
\alguma coisa aqui
}
});
If you understood what I meant, now comes my doubt; I'm wondering how to do this with some value of a setting being set to a <select>
.
<select id="exemplo">
<option value="exemplofoi">Padrão</option>
<option value="exemplofoi2">Extra</option>
</select>
If you have not understood, I'm looking to use the storage.get to activate a javascript only when this value is active on the extension settings page.
Answer:
storage.get(function(settings) {
if (settings.exemplo === undefined) {
settings.exemplo = false;
storage.set({'exemplo': settings.exemplo});
}
if (settings.exemplo == 'exemplofoi') {
\alguma coisa aqui
}
});