User:The last username left/skinswitch.js

function forceOasisOn { document.cookie = "useOasis=yes"; var href = location.href; var anchor = ""; if (href.indexOf("#") != -1) {   href = href.split("#"); anchor = "#" + href[1]; href = href[0]; } if (href.indexOf("?") != -1) location.href = href + "&useskin=wikia" + anchor; else location.href = href + "?useskin=wikia" + anchor; }

function forceOasisOff { document.cookie = "useOasis=no"; location.href = location.href.split("&useskin=wikia").join("").split("?useskin=wikia&").join("?").split("?useskin=wikia").join(""); }

$(function{ /* Add switch buttons - modified from http://dev.wikia.com/index.php?title=SkinSwitchButton/beta.js */  switch (skin)  {    case 'answers': //pass to monaco    case 'awesome':    case 'monaco':      var li = $(" ");      var img = $(" ");      img.attr("src", "/skins/common/blank.gif").addClass("sprite search");      var a = $("");      a.attr("id", "ca-skins").attr("rel", "nofollow").attr("href", "#").text("Oasis").click(forceOasisOn);      li.append(img).append(a);      $("#page_controls").append(li);      break;    case 'uncyclopedia': //pass to monobook    case 'wikiaphone':    case 'monobook': //        $('Monaco Oasis').appendTo('#p-cactions > .pBody > ul'); //Too lazy to code in monobook so far break; case 'oasis': var li = $(" "); li.attr("id", "ca-skins"); var a = $(""); a.attr("id", "ca-skins").attr("href", "#").text("Monaco").css("border", "0px").click(forceOasisOff); li.append(a); $("#WikiHeader").append(li); break; } /* Are we set on Oasis? */ var cookie = document.cookie.match('(^|;) ?useOasis=([^;]*)(|$)'); if (!cookie || unescape(cookie[2]) != "yes") return;

/* Check location */ if(location.href.indexOf("useskin=wikia") == -1) {   var href = location.href; var anchor = ""; if (href.indexOf("#") != -1) {     href = href.split("#"); anchor = "#" + ref[1]; href = href[0]; }   if (href.indexOf("?") != -1) location.href = href + "&useskin=wikia" + anchor; else location.href = href + "?useskin=wikia" + anchor; }

/* Alter all internal links to include useskin=wikia */ $("a[href^='/'],a[href*='.wikia.com/']").each(function{   var href = $(this).attr("href");    var anchor = "";    if (href.indexOf("#") != -1)    {      href = href.split("#");      anchor = "#" + href[1];      href = href[0];    }    if (href.indexOf("?") != -1)      $(this).attr("href", href + "&useskin=wikia" + anchor);    else      $(this).attr("href", href + "?useskin=wikia" + anchor);  }); });