Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dandiebolt/897266 to your computer and use it in GitHub Desktop.
Save dandiebolt/897266 to your computer and use it in GitHub Desktop.
lernantatron
// ==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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment