1
0
Fork 0

global injection

This commit is contained in:
Lukas Winkler 2017-09-02 21:52:20 +02:00
parent 95ff1046b8
commit 70a6c5e336
2 changed files with 28 additions and 4 deletions

View file

@ -35,7 +35,21 @@ globalEl.addEventListener("click", function() {
});
document.getElementById("save").addEventListener("click", function() {
chrome.storage.sync.set({global:globalEl.checked}, function() {
window.close()
})
chrome.storage.sync.set({global: {enabled: globalEl.checked, js: editor.getValue()}}, function() {
window.close();
});
});
chrome.storage.sync.get("global", function(items) {
if (items && Object.keys(items).length !== 0) {
var global = items.global;
editor.setValue(global.js);
editor.gotoLine(1);
globalEl.checked = global.enabled;
editor.setOptions({
readOnly: !global.enabled,
highlightActiveLine: global.enabled,
highlightGutterLine: global.enabled
});
}
});

View file

@ -31,4 +31,14 @@
}
}
});
chrome.storage.sync.get("global", function(items) {
if (items && Object.keys(items).length !== 0) {
var global = items.global;
if (global.enabled) {
setTimeout(function() {
injectScript(generateScriptDataUrl(global.js), 'body');
}, 250);
}
}
});
})();