User:Alphax/move-tabs.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/* <pre><nowiki> */

function move_tabs()
{
    tabs = document.getElementById("p-cactions").getElementsByTagName("ul")[0];
    // only really the username if it's a user or user talk page
    username = wgPageName.substring(wgPageName.indexOf(':') + 1).split('/')[0];
    // if IP
    userIsIp = false;
    if(username.match(/\d+\.\d+\.\d+\.\d+/))
    {
        userIsIp = true;
    }
    
    // Namespace numbers are (see [[m:Help:Variables]]):
    // -1: Special
    // 2:  User
    // 3:  User_talk
    // 6:  Image
    // 7:  Image_talk
    // 14: Category
    switch(wgNamespaceNumber)
    {
        case -1:
            if(wgPageName == "Special:CheckUser")
            {
                addlilink(tabs, 'javascript:openWindow("/wiki/User:" + prompt("Username or IP?"))', "User/IP page");
            }
            break;
        case 2:
        case 3:
            userfuncs = addlimenu(tabs, "user functions", "ca-userfuncs");
            userfuncs.appendChild(document.getElementById("ca-gallery"));
            userfuncs.appendChild(document.getElementById("ca-orphans"));
            userfuncs.appendChild(document.getElementById("ca-untagged"));
            // add custom tabs
            addlilink(userfuncs, "/wiki/Special:Blockip/" + username, "block user");
            addlilink(userfuncs, "/wiki/Special:Log/block?page=User:" + username, "block log");
            addlilink(userfuncs, "/w/index.php?title=Special:Ipblocklist&action=unblock&ip=" + username, "unblock user");
            addlilink(userfuncs, "/wiki/Special:Contributions/" + username, "contributions");
            if(userIsIp)
            {
                addlilink(userfuncs, "http://www.samspade.org/t/lookat?a=" + username, "samspade whois");
                addlilink(userfuncs, "http://www.dnsstuff.com/tools/whois.ch?ip=" + username, "dnsstuff whois");
                addlilink(userfuncs, "http://www.completewhois.com/cgi-bin/rbl_lookup.cgi?query=" + username + "&display=webtable", "completewhois");
                addlilink(userfuncs, "http://all-nettools.com/toolbox", "nettools");
                addlilink(userfuncs, "http://tools.wikimedia.de/~essjay/nqt.php?portNum=8080&queryType=all&target=" + username + "&Submit=Do+It", "essjay's nqt");
                addlilink(userfuncs, "http://rbls.org/?q=" + username, "rbls lookup");
                addlilink(userfuncs, "http://vcn-proxycheck.homeip.net/?ip=" + username, "vcn proxycheck");
                addlilink(userfuncs, "/wiki/Special:CheckUser?ip=" + username, "checkuser");
            }
            else
            {
                addlilink(userfuncs, "/wiki/Special:CheckUser?user=" + username, "checkuser");
            }
            break;
        case 6:
        case 7:
            imagefuncs = addlimenu(tabs, "image functions", "ca-imagefuncs");
            imagefuncs.appendChild(document.getElementById("ca-checkusage"));
            imagefuncs.appendChild(document.getElementById("ca-commonsense"));
            imagefuncs.appendChild(document.getElementById("ca-log"));
            if(document.getElementById("ca-unthumb"))
            {
                imagefuncs.appendChild(document.getElementById("ca-unthumb"));
            }
            imagefuncs.appendChild(document.getElementById("ca-" + tab_wikipedia + "wiki"));
            if(document.title.indexOf("Editing") == 0)
            {
                addlilink(imagefuncs, 'javascript:markFlickrReviewed()', "flickr ok");
                addlilink(imagefuncs, 'javascript:markFlickrReviewed(prompt("License?"))', "flickr wrong");
            }
            break;
        case 14:
            // do nothing, there are very few tabs
            break;
        default:
            // nothing
    }
}

function markFlickrReviewed(license)
{
    if(license) // need window.license on FF-1.5
    {
        if((license == "Cc-by-2.0") || (license == "Cc-by-sa-2.0"))
        {
            document.getElementById("wpTextbox1").value =
             document.getElementById("wpTextbox1").value.replace(/{{cc-.*}}/i, "{{" + license + "}}");
            license = "";
        }
        else
        {
            license = "|" + license;
        }
    }
    else
    {
        var license = "";
    }
    
    document.getElementById("wpTextbox1").value =
        document.getElementById("wpTextbox1").value.replace(/(flickrreview)/i, "$1|Alphax|" + timestamp.replace(/\//g, "-") + license);
    
    document.getElementById("wpSummary").value = "Reviewed Flickr tag";
    document.getElementById("wpSave").click();
}

addOnloadHook( move_tabs );

/* </nowiki></pre> */