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; }

if(window.location.href.indexOf("useskin=") == -1) window.location.href = work(window.location.href);

//$(function {   var youarehere = escape(wgPageName); //    var youarehere = mw.html.escape(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'); //});

/* //addOnloadHook(function { var links = document.links;  for (i in links)    if ( links[i].href.indexOf("/wiki/") != -1 )      links[i].href = work(links[i].href); //});

function workout(beforeunload) { beforeunload.target.href = work(beforeunload.target.href); }

window.addEventListener( "beforeunload", workout, true );