User:Ilmari Karonen/rblcheck.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.

// RBL CHECK LINK: <pre><nowiki>

addOnloadHook(function () {
    var href = document.getElementById('t-contributions');
    if (href) href = href.getElementsByTagName('a');
    if (href) href = href[0];
    if (href) href = href.href;
    else href = window.location.href;

    var addr = /(\/wiki\/|[?&]title=)Special:Contributions(\/([^\/?&#]*)|[?&#]|$)/.exec(href);
    if (!addr) return;
    addr = addr[3];
    if (!addr) {
        addr = /^[^?#]*\?([^&#]*&)*target=([^&#]*)/.exec(href);
        if (!addr) return;
        addr = addr[2];
    }
    if (!/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/.test(addr)) return;

    addLink('p-tb', 'http://www.robtex.com/rbls/'+addr+'.html', 'RBL check', 't-rblcheck', 'Multi-RBL check', null, 't-contributions');
});

// </nowiki></pre>