Files
webextensions-examples/content-scripts/content-script.js
Will Bamberg 11fe52f05a extension work
2015-09-14 16:49:43 -07:00

29 lines
642 B
JavaScript

chrome.runtime.onMessage.addListener(handleMessage);
function handleMessage(request, sender, sendResponse) {
switch(request.name) {
case "highlight-para":
highlightPara();
break;
case "show-foo":
showFoo();
break;
case "call-confirm":
callConfirm();
}
}
function highlightPara() {
var pageScriptPara = document.getElementById("page-script-para");
pageScriptPara.style.backgroundColor = "blue";
}
function showFoo() {
var output = document.getElementById("output");
output.textContent = "window.foo=" + window.foo;
}
function callConfirm() {
window.confirm("Are you sure?");
}