User:TheDragonFire/common.js

// Automatically use MonoBook for all pages. // You are free to copy this script if you are an Oasis-hater, however, please don't do it when it is unverified. // This script does not work when you are editing your common.js page. // Verified: NO

// Code imported from Rethering (Script) RPG, one of my JS projects. // Thanks to nickf. // https://stackoverflow.com/questions/1586330/access-get-directly-from-javascript var parts = window.location.search.substr(1).split("&"); var $_GET = {}; for (var i = 0; i < parts.length; i++) { var temp = parts[i].split("="); $_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]); }

// Get the URL. url = window.location.href;

/* // Check if useskin= is already present, I might actually be using Oasis! Other // checks are also carried out. if ($_GET["useskin"] == null && $_GET["nombrd"] == null && $_GET["nomb"] == null) { // If no parameters are in URL use question mark standalone string if ($_GET["action"] == null && $_GET["printable"] == null && $_GET["preview"] == null && $_GET["search"] == null && $_GET["curid"] == null && $_GET["diff"] == null && $_GET["undoafter"] == null && $_GET["veaction"] == null && $_GET["file"] == null && $_GET["redirect"] == null && $_GET["nomb"] == null && $_GET["nombrd"] == null && $_GET["nombwikilinks"] == null) { window.location.href(url + '?useskin=monobook&rd=oasis2monobook'); // Else add an ampersand } else { window.location.href(url + '&useskin=monobook&rd=oasis2monobook'); } } if ($_GET["rd"] !== null) { if ($_GET["rd"] == "oasis2monobook") { console.log("You were redirected from the Oasis skin to the MonoBook skin. To disable this, please add ?nomb=1 to your URL, as in community.wikia.com/wiki/Main_Page?nomb=1") } }

// Make all links use MonoBook. Note that this behaviour can break external links as no check exists for them. if ($_GET["nombwikilinks"] == null && $_GET["nomb"] == null) { var wikilinks = document.getElementsByTagName('a'); for (var wikilinknumber = 0; wikilinknumber < wikilinks.length; wikilinknumber++) { if (wikilinks[wikilinknumber].href.indexOf('?') != -1) { wikilinks[wikilinknumber].href += '&useskin=monobook&rd=automonobook'; } else { wikilinks[wikilinknumber].href += '?useskin=monobook&rd=automonobook'; }   }

}