Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css');

function addTab(url, name, id, title, key){ 
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    addlilink(tabs, url, name, id, title, key);
}
 
function morelinks()
{
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if((wgNamespaceNumber == 2 || wgNamespaceNumber == 3) || (wgNamespaceNumber == -1 && wgCanonicalSpecialPageName == "Contributions"))
    { 
         var editlk = wgTitle;
            var slloc = editlk.indexOf('/');
            if(slloc > 0) editlk = editlk.substring(0, slloc);
         var anon= IPhandler(editlk);
 
        // format: addlilink(userf, url, name);
 
        // add "block" tab
        addlilink(tabs, '/wiki/Special:Blockip/' + editlk, 'block user', '');
 
        // add "blocklog" tab
        addlilink(tabs, '/wiki/Special:Log/block?page=User:' + editlk, 'block log', '');
 
        // add "unblock" tab
        addlilink(tabs, '/w/index.php?title=Special:Ipblocklist&action=unblock&ip=' + editlk, 'unblock', '');
 
        // add "contributions" tab
        addlilink(tabs, '/wiki/Special:Contributions/' + editlk, 'contribs', '');   
 
        if (anon != true)
        {
        // add "user log" tab
        addlilink(tabs, '/w/index.php?title=Special:Log&type=&user=' + editlk, 'user log', '');
        }
 
        // add "edit count" tab
        addlilink(tabs, 'http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=' + editlk + '&site=en.wikipedia.org', 'editcount', '');
 
        if (anon == true)
        {
        // add "whois" tab
        addlilink(tabs, 'http://samspade.org/whois/' + editlk, 'whois', '');
 
        // add "RDNS" tab
        addlilink(tabs, 'http://openrbl.org/query?' + editlk, 'RDNS', '');
        }
     }
}

function addlilink(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

function IPhandler(PossIP)
{
           var count = 0
           while (perp != -1)
           {
           var IP;
           var perp = PossIP.indexOf('.');
           if (perp == -1)
           {
            IP = PossIP.substring(0, PossIP.length)
           }
           else
           {
           IP = PossIP.substring(0, perp);
           }
           var check = Iptest(IP);
           if (check != 1)
           {
           return false;
           }
           else
           {
           PossIP = PossIP.substring(perp + 1, PossIP.length)
           count++;
           }    
}
       if (count == 4)
       return true;  
       else
       return false;
}
function Iptest(Num)
{
    if (Num >=0 && Num <= 255)
    return 1;
}

$(morelinks());