User:Eyes/STO redirect patch

This Javascript can serve as a temporary patch to place redirect notices into the STO skin. It has been tested on two other wikis and verified to function there, but it was not possible for me to test it directly on this skin. I find it unlikely this skin will cause any issues, but I can't guarantee it 100% until it is tested here.

The code to be placed in MediaWiki:Common.js to enable this patch: function addRedirectNotice { if (skin == "monobook" && document.getElementsByTagName("div")[0].className == "userinfo_box") {   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?title=" + 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);

Ideally, the skin itself needs to be fixed, but this can't be done through the wiki. It needs to be done by someone with direct access to the files making up the skin.