User:Handheld/global.js

function work(href) { var anchor = ""; if (href.indexOf("#") != -1) {     href = href.split("#"); anchor = "#" + href[1]; href = href[0]; }   if (href.indexOf("?") != -1) if (href.indexOf("useskin=") == -1) { return href + "&useskin=wikiaphone" + anchor; } else { return href + anchor; }   else return href + "?useskin=wikiaphone" + anchor; } $(function { if(window.location.href.indexOf("useskin=") == -1)    window.location = work(window.location.href); });

addOnloadHook(function { var youarehere = encodeURIComponent(wgPageName);  addPortletLink ('p-cactions', '/wiki/' + youarehere + '?useskin=wikiaphone', 'phone');  addPortletLink ('p-cactions', '/wiki/' + youarehere + '?useskin=monobook&handheld=yes', 'handheld');  addPortletLink ('p-cactions', '/wiki/' + youarehere + '?useskin=wikiamobile', 'mobile');  $("a[href^='/'],a[href*='.wikia.com/']").each(function{ $(this).attr("href", work($(this).attr("href"))); }); });