Added an example for contentScripts.register

This commit is contained in:
Will Bamberg
2017-12-12 09:02:11 -06:00
parent 8b5f320c1a
commit 6377f7952a
8 changed files with 138 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
'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;
async function registerScript() {
let background = await browser.runtime.getBackgroundPage();
background.register(hostsInput.value.split(","), codeInput.value)
}
document.querySelector("#register").addEventListener('click', registerScript);