Skip to content

Instantly share code, notes, and snippets.

@ajsb85
Forked from bogomil/jpbutton.js
Created October 22, 2011 05:27
Show Gist options
  • Save ajsb85/1305679 to your computer and use it in GitHub Desktop.
Save ajsb85/1305679 to your computer and use it in GitHub Desktop.
Mozilla JetPack example - create a button on page
var buttonScript = [
'var butt = document.createElement("button");', //define button element
'var btext = document.createTextNode("Click me");', //define the text
'butt.appendChild(btext);', //attach text to the button
'butt.addEventListener("click", function(){document.bgColor="red"} , false)', //handle onclick event
'document.getElementById("test").appendChild(butt);', //put the button on the page
];
var pageButton = require("page-mod").PageMod({
include: 'http://talkweb.eu/labs/jetpack/button.html', // this script will works only on this website
contentScriptWhen: 'ready',
contentScript: buttonScript
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment