User:Mike Dillon/Scripts/toolboxTool2Link.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
// Requires: [[User:Mike Dillon/Scripts/i18n.js]], [[User:Mike Dillon/Scripts/username.js]]
 
/* <pre><nowiki> */
 
/* Messages */
wfAddMsg("en", "toolboxTool2LinkLabel", "User edit count");
wfAddMsg("es", "toolboxTool2LinkLabel", "Cuenta de edicions");
wfAddMsg("en", "toolboxTool2LinkTitle", "View this user's edit count");
wfAddMsg("es", "toolboxTool2LinkTitle", "Ver la cuenta de ediciones de este usuario");
 
if (typeof(generate_input_form) != typeof(function () {})) {
    importScript('User:Interiot/Tool2/code.js');
}
 
// Add a link to User:Interiot/Tool2/code.js to the p-tb bar.
addOnloadHook(function () {
    // Skip non-user pages
    if (document.getElementById("t-contributions") == null &&
        wgCanonicalSpecialPageName != "Contributions") {
        return;
    }
 
    // Skip subpages
    if (wgTitle.indexOf("/") != -1) return;
 
    // Skip if the username can't be deteremined
    var username = getUsernameForCurrentPage();
    if (!username) return;
 
    var url = wgArticlePath.replace(/\$1/, 'User:Interiot/Tool2/code.js');
    url += "?username=" + encodeURIComponent(username);
 
    addPortletLink('p-tb', url, wfMsg("toolboxTool2LinkLabel"), 't-editcount',
        wfMsg("toolboxTool2LinkTitle"), null,
        document.getElementById('t-emailuser') || document.getElementById('t-upload'));
});
 
/* </nowiki></pre> */