User:Lupin/nichalp links.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Lupin/nichalp links. |
// culled from [[User:Lupin/popups.js]]
function nichalp_articleFromURL(h) {
if (typeof h != 'String') h=String(h);
h=decodeURI(h);
var m=RegExp('[^:]*://en\\.wikipedia\\.org/(wiki/|w/index\\.php\\?title=)([^&?]*)').exec(h);
if(m===null) return null;
return m[2];
}
function nichalp_isIpUser(user) {
return RegExp('(User:)?' +
'((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}' +
'(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])')
.test(user);
}
function nichalp_removeAnchor(article) {
// is there a #? if not, we're done
var i=article.indexOf('#');
if (i == -1) return article;
return article.substring(0,i);
}
function nichalp_userName(article) {
var i=article.indexOf('User');
var j=article.indexOf(':');
if (i != 0 || j == -1) return null;
var k=article.indexOf('/');
if (k==-1) return article.substring(j+1);
else return article.substring(j+1,k);
}
// do it
function nichalp_customLinks() {
addPurge();
var article=nichalp_articleFromURL(document.location.href);
if (!article) return;
var user=nichalp_userName(article);
if(!user) return;
user=nichalp_removeAnchor(user);
if (!nichalp_isIpUser(user)) {
addToolboxLink('http://kohl.wikimedia.org/~kate/cgi-bin/count_edits?dbname=enwiki&user='+user, user+"'s edit count", 'toolbox_katestool');
}
var special='http://wiki.riteme.site/w/index.php?title=Special:';
addToolboxLink(special + 'Contributions/' + user, user+"'s contribs", 'toolbox_usercontribs');
addToolboxLink(special + 'Log&user='+user, user+"'s log", 'toolbox_userlog');
addToolboxLink(special + 'Blockip&ip='+user, 'Block '+user, 'toolbox_blockuser');
addToolboxLink(special + 'Special:Ipblocklist&action=unblock&ip='+user, 'Unblock '+user, 'toolbox_unblockuser');
}
// make it all happen on page load
addOnloadHook(nichalp_customLinks);