There are 5 previous versions of this script.
// ==UserScript==
// @name Popodeus: Popmundo Login Server Select
// @namespace http://popodeus.com
// @description Lets you select the server you want to login to in Popmundo.com and shows mini statistics.
// @include http://www*.popmundo.com/Common/entry.asp
// @include http://www*.popmundo.com/Common/Credits.asp
// @copyright Popodeus.com, 2009. All rights reserved. No right to alter or redistribute.
// @version 3
// ==/UserScript==
var version = 3;
window.addEventListener('load', function() {
if (top != window) {
top.location = window.location;
}
function X(xpath) {
var elem = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if (elem && elem.snapshotLength >= 1)
return elem.snapshotItem(0);
else return null;
}
function elem(name, attrs, style, text) {
var e = document.createElement(name);
var key;
if (attrs) for (key in attrs) e.setAttribute(key, attrs[key]);
if (style) for (key in style) e.style[key] = style[key];
if (text) e.appendChild(document.createTextNode(text));
return e;
}
function img(val,when) {
return 'http://popodeus.com/scripts/server-select/img/'+val+'-'+when;
}
function domainImg(when) {
return 'http://popodeus.com/scripts/server-select/img/'+document.domain.match(/www(\d+)/)[1]+'-'+when;
}
if (location.href.indexOf('Credits.asp') > 0) {
document.appendChild(elem('img',{src:domainImg('out')}));
return;
}
// Yes, this xpath is ugly... But we can live with it for now.
var tbl = X('/html/body/table[3]/tbody/tr/td/table[1]/tbody/tr[2]/td[2]/div/table');
if (tbl) {
var frm = X('//form[@name="GameLogin"]');
var num = frm.action.match(/www(\d+)/)[1];
var tr = elem('tr');
var td = elem('td', null, null, 'Select server:');
tr.appendChild(td);
tbl.appendChild(tr);
tr = elem('tr');
td = elem('td', {colspan:2},{verticalAlign:'bottom'});
var sel = elem('select');
var i, x;
var wasselected = false;
for (i = 120; i <= 126; i++) {
x = {};
if (i == num) {
x.selected = 'selected';
wasselected = true;
}
sel.appendChild(elem('option', x, null, i));
}
if (!wasselected) sel.appendChild(elem('option', {selected:'selected'}, null, num));
td.appendChild(sel);
var a = elem('a',{href:'http://userscripts.org/scripts/show/42299'});
a.appendChild(elem('img',{align:'absbottom',alt:'Server Select by Popodeus.com',id:'x-stats',src:img(num,'initial')}));
td.appendChild(a);
tr.appendChild(td);
tbl.appendChild(tr);
sel.addEventListener('change', function() {
frm.action = frm.action.replace(/www\d+/, 'www' + sel.value);
document.getElementById('x-stats').src = img(sel.value,'change');
}, false);
frm.addEventListener('submit', function() {
document.appendChild(elem('img',{src:img(sel.value,'go'),width:1,height:1}));
}, false);
}
}, true);
