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("handheld=") == -1) { return href + "&handheld=yes" + anchor; } else return href + anchor; } else return href + "?handheld=yes" + anchor; }

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

addPortletLink ('p-cactions', '/wiki/' + mw.html.escape(wgPageName) + '?useskin=wikiamobile', 'mobile');

window.onload = (function { var links = document.links;  for (i=0; i<links.length; i++)    if ( links[i].href.indexOf("/wiki/") != -1 )      links[i].href = work(links[i].href); });