Skip to content

Instantly share code, notes, and snippets.

@bogomil
Created May 13, 2011 07:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bogomil/970120 to your computer and use it in GitHub Desktop.
Save bogomil/970120 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