User:Jclemens/monobook.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
$(function() {
if (wgServer != 'https://secure.wikimedia.org') return;
var re = /^http\:\/\/(.*?)\.wik(ipedia|isource|ktionary|ispecies|iquote|ibooks|imedia|inews|iversity)\.org(\/.*?)$/;
var remw = /^http\:\/\/(www\.)?mediawiki.org(\/.*?)$/;
var links = document.getElementsByTagName('a');
for (var i = links.length; i--;) {
var link = links[i];
if (matches = link.href.match(re)) {
if (matches[1] == 'mail') continue;
if (matches[1] == 'lists') continue;
if (matches[1] == 'upload') continue;
if (matches[3] == '/') matches[3] = '/wiki/';
if (matches[1] == 'meta') {
var n = 'https://secure.wikimedia.org/wikipedia/meta' + matches[3];
} else {
if (matches[1] == 'commons') {
var n = 'https://secure.wikimedia.org/wikipedia/commons' + matches[3];
} else {
var n = 'https://secure.wikimedia.org/wik' + matches[2] + '/' + matches[1] + matches[3];
}
}
link.href = n; link.title = n;
if (link.innerHTML.match(re)) link.innerHTML = n;
continue;
}
if (matches = link.href.match(remw)) {
var n = 'https://secure.wikimedia.org/wikipedia/mediawiki' + matches[2];
link.href = n; link.title = n;
if (link.innerHTML.match(remw)) link.innerHTML = n;
}
}
});