User:Hersfold/extratabs.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:Hersfold/extratabs. |
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());