User:Brobdingnag~enwiki/monobook.js

// interwiki var interwikiOrder = new Array;

function containsInterwiki(kids, interWikiID) { for (var i = 0; i < kids.length; i++) { if ( kids[i].className == ('interwiki-' + interWikiID) ) return i; } return -1; }

function fixInterwikiOrder { var kids = document.getElementById('p-lang').getElementsByTagName('LI'); var removeAllOthers = (interwikiOrder[interwikiOrder.length - 1] == 'fin') ? 2 : 1; for (var i = interwikiOrder.length - removeAllOthers; i > -1; i--) { var interWikiIndex = containsInterwiki(kids, interwikiOrder[i]); if (interWikiIndex != -1) { var father = document.getElementById('p-lang').getElementsByTagName('UL')[0]; father.insertBefore(kids[interWikiIndex], father.firstChild); } } if (removeAllOthers == 2) while (kids.length != interwikiOrder.length - 1) father.removeChild(father.lastChild); }

function initInterwikiOrder { if (!document.getElementById('p-lang')) return; var a = sajax_init_object; a.open('GET', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?title=User:' + encodeURIComponent(wgUserName) + '/interwiki&action=raw', true); a.onreadystatechange = function { if (a.readyState != 4) return; var lines = a.responseText.split('\n'); var rx = new RegExp('\\*\\s?([^$]*)'); for (var i = 0; i < lines.length; i++) { var m = rx.exec(lines[i]); if (m) interwikiOrder.push(m[1]); else break; } if (interwikiOrder[0]) fixInterwikiOrder; } a.send(null); }

$(initInterwikiOrder);

// catwatch importScript('User:Ais523/catwatch.js');