Added an example for contentScripts.register (#325)

* Added an example for contentScripts.register

* Use messaging instead of getBackgroundPage
This commit is contained in:
wbamberg
2018-01-26 13:11:06 -08:00
committed by GitHub
parent 5d20372527
commit 33d8fba6a8
8 changed files with 145 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
'use strict';
const hostsInput = document.querySelector("#hosts");
const codeInput = document.querySelector("#code");
const defaultHosts = "*://*.org/*";
const defaultCode = "document.body.innerHTML = '<h1>This page has been eaten<h1>'";
hostsInput.value = defaultHosts;
codeInput.value = defaultCode;
function registerScript() {
browser.runtime.sendMessage({
hosts: hostsInput.value.split(","),
code: codeInput.value
});
}
document.querySelector("#register").addEventListener('click', registerScript);