global injection
This commit is contained in:
parent
95ff1046b8
commit
70a6c5e336
2 changed files with 28 additions and 4 deletions
|
@ -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
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
10
js/run.js
10
js/run.js
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
Reference in a new issue