Skip to content

Instantly share code, notes, and snippets.

@dandiebolt
Created October 24, 2011 15:23
Show Gist options
  • Save dandiebolt/1309308 to your computer and use it in GitHub Desktop.
Save dandiebolt/1309308 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Baby Badger Bootstrapper
// @namespace BabyBadge
// @include *
// @author Dan Diebolt
// @description Embeds thumbnail of baby on every page
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function main() {
$("<img>").attr({
src: "http://distillery.s3.amazonaws.com/media/2011/10/19/6cb52a68db1b4a9bbed164f84843bf6e_7.jpg",
width: 100,
height: 100
}).prependTo("body:first").css({position: "fixed", top: "0px", right: "0px","z-index": 100});
}
// load jQuery and execute the main function
addJQuery(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment