User:Karika/STO.js

function addRedirectNotice { if (skin == "STO") {   var requestedPageName = ""; var titleRegExp; if (document.location.pathname.indexOf("/index.php") == 0) {     titleRegExp = new RegExp("(?:^|[?&;])(?:title=)(.*?)(?:[&;]|$)"); requestedPageName = decodeURIComponent(document.location.search.match(titleRegExp)[1]); }   else {     titleRegExp = new RegExp("(?:/)(.*?)(?:[&;]|$)"); requestedPageName = decodeURIComponent(document.location.pathname.match(titleRegExp)[1]); }

if (requestedPageName != wgPageName) {     var beginNotice = document.createTextNode("(redirected from ");      var endNotice = document.createTextNode(")");

var linkText = document.createTextNode(requestedPageName.replace(/_/g, " "));

var link = document.createElement("a"); link.setAttribute("href", wgServer + "/index.php/" + requestedPageName + "&redirect=no"); link.appendChild(linkText);

var notice = document.createElement("div"); notice.style.color = "#dddddd"; notice.style.fontSize = "80%"; notice.style.paddingLeft = "2em"; notice.appendChild(beginNotice); notice.appendChild(link); notice.appendChild(endNotice); var headings = document.getElementsByTagName("h1"); headings[0].parentNode.insertBefore(notice, headings[0].nextSibling); } } }

addOnloadHook(addRedirectNotice);