Jump to content

User:Paranomia/usertab.js

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Ladsgroup (talk | contribs) at 07:42, 29 November 2021 (Maintenance: Replacing addPortletLink() with mw.util.addPortletLink() (mw:ResourceLoader/Migration_guide_(users)#addPortletLink)). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
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 isIPAddress( string ){
	var res = /(\d{1,4})\.(\d{1,3})\.(\d{1,3})\.(\d{1,4})/.exec( string );
	return res != null && res.slice( 1, 5 ).every( function( e ) { return e < 256; } );
}
$(function() {


    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if((wgCanonicalNamespace == 'User' || wgCanonicalNamespace == 'User_talk') && (wgAction == 'view' || document.getElementById('newarticletext')))
    {
        editlk = wgTitle;
        var slloc = editlk.indexOf('/');
        if(slloc > 0) editlk = editlk.substring(0, slloc);
        if(!isIPAddress(editlk)) {
        addlimenu(tabs, 'User', 'userf');
        var userf = document.getElementById('userf').getElementsByTagName('ul')[0];
 
        // format: addlilink(userf, url, name);
 
        // add "listusers" tab
        // addlilink(userf, '/w/index.php?title=Special:Listusers&group=&username=' + editlk, 'list', '');

        // add "check blocked" tab
        // addlilink(userf, 'http://en.wikipedia.org/w/index.php?title=Special%3AIpblocklist&ip=' + editlk, 'check blocked', '');
        // addTab('http://en.wikipedia.org/w/index.php?title=Special%3AIpblocklist&ip=' + editlk, 'check blocked');
 
        // add "contributions" tab
        addlilink(userf, '/wiki/Special:Contributions/' + editlk, 'contribs', '');
        // addTab('/wiki/Special:Contributions/' + editlk, 'con');
 
        // add "logs" tab
        addlilink(userf, '/w/index.php?title=Special:Log&user=' + editlk, 'log', '');
 
        // add "userspace" tab
        addlilink(userf, '/w/index.php?title=Special:Prefixindex&namespace=2&from=' + editlk, 'subpages', '');
        addlilink(userf, 'javascript:get_editcount_json(\'' + editlk + '\')', 'count (quick)', '');
        // add "edit count" tab
        addlilink(userf, 'http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=' + editlk + '&site=en.wikipedia.org', 'count (full)', '');
        // addTab('http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=' + editlk + '&site=en.wikipedia.org', 'count');
        // add email tab
        addlilink(userf, '/wiki/Special:EmailUser/' + editlk, 'email', '');
        // add "edit summary usage" tab
        addlilink(userf, 'http://www.math.ucla.edu/~aoleg/wp/rfa/edit_summary.cgi?user=' + editlk, 'summary usage', '');
        // addTab('http://www.math.ucla.edu/~aoleg/wp/rfa/edit_summary.cgi?user=' + editlk, 'summary usage');
        addlilink(userf, 'javascript:get_blocked_json(\'' + editlk + '\')', 'check blocked', '');
        addlilink(userf, 'javascript:get_userlist_xml(\'' + editlk + '\')', 'rights', '');
        addlilink(userf, 'http://en.wikipedia.org/w/index.php?title=User_talk:' + editlk + '&action=edit&section=new', 'leave message', '');
        // addTab('http://en.wikipedia.org/w/index.php?title=User_talk:' + editlk + '&action=edit&section=new', 'leave message');
        }
       // ip stuff
       // if(isIPAddress(editlk)) mw.util.addPortletLink('p-cactions', 'http://hemlock.ts.wikimedia.org/~krimpet/torcheck.php?ip=' + editlk, 'tor', '');
    }
});