// ==UserScript==
// @name Random Buttercup Festival Series I
// @namespace buttercupfestival.com
// @include http://buttercupfestival.com/index*
// ==/UserScript==
(function () {
//archive page to scrape links from
var archFrame = document.createElement("iframe");
archFrame.src = "http://buttercupfestival.com/archive.htm";
archFrame.style.display = "none";
document.body.appendChild(archFrame);
//create popup
var p = document.createElement("div");
p.setAttribute("style", "display:none; position:absolute; top:0; width:100%; height:100%; background:#eee;");
//iframe in popup
var iframe = document.createElement("iframe");
iframe.setAttribute("style", "width:100%; height:95%; margin-top:3em")
p.appendChild(iframe)
document.body.appendChild(p);
//randomize link box
var hook = document.createElement("div");
hook.setAttribute("style", "position:absolute; top:0; right:0; width:100px; height:2em; padding:.5em; background:#eee; text-align:center;");
var a = document.createElement("a");
a.innerHTML = "Random Strip"
a.href="#";
a.addEventListener("click",function(){
p.style.display = "block";
a.style.display = "inline";
randomize();
}, true);
hook.appendChild(a);
a = document.createElement("a");
a.innerHTML = " Hide"
a.setAttribute("style", "display:none");
a.href="#";
a.addEventListener("click",function(){
p.style.display = "none";
a.style.display = "none";
}, true);
hook.appendChild(a);
document.body.appendChild(hook);
function randomize(){
var e = document.evaluate("//a", archFrame.contentDocument, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var selection = e.snapshotItem(Math.floor(Math.random()*e.snapshotLength) + 1);
iframe.src = selection.href;
return false;
}
})();