// ==UserScript== | |
// @name Lernantatron Bootstrapper | |
// @namespace Lernantatron | |
// @include http://new.p2pu.org/* | |
// @author Dan Diebolt | |
// @description This userscript is a bootstrapper to load additional | |
// JavaScript files identified by Lernantatron Markup within P2PU's | |
// Lernanta platform | |
// ==/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() { | |
//reduce chance of epileptic seizure | |
$("body").css("background","#FFFFFF"); | |
if (document.location.href.split("/")[8] == "edit") return; | |
var lembed=$("div#main:has(p:contains({lernantatron:))").text(); | |
var lembed2=lembed.split(":")[1].split("}")[0]; | |
var url = "https://gist.github.com/" + lembed2; | |
if (lembed2.length>0) { | |
$.getScript(url); | |
} | |
} | |
// load jQuery and execute the main function | |
addJQuery(main); |