User:Tierrie/global.js

var hasClass = (function { var reCache = {}; return function (element, className) { return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); }; });

function initSpoilers { contentstart = document.getElementById("bodyContent"); var Spans = document.getElementsByTagName("span"); for (i=0;i<Spans.length;i++) { if (hasClass(Spans[i], "spoiler")) { Spans[i].setAttribute("id", "spoiler" + i); alert(i + ": " + Spans[i].innerHTML); } } }

spoilers = true; function loadSpoilers { if(spoilers) initSpoilers; }

addOnloadHook(loadSpoilers);