User:Versageek/vector.js

From Wikipedia, the free encyclopedia
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.
// <nowiki>
//document.write('<style>');
//document.write('#siteNotice { display: none; } ');
//document.write('</style>');
// importScript('User:Lupin/popups.js');
importScript('User:Beetstra/Gadget-Spam-blacklist-Handler.js');
importScript("User:Animum/easyblock.js"); //[[User:Animum/easyblock.js]]
importScript('User:Anomie/util.js');
importScript('User:Anomie/previewtemplatelastmod.js'); // Linkback:[[User:Anomie/previewtemplatelastmod.js]]
// importScript('User:Versageek/isblocked.js');
//
// importScript('User:AzaToth/twinkle.js');

importScript('User:Splarka/contribsrange.js');
// importScript("User:Mr.Z-man/moverevert.js");
importScript('User:Amalthea/culoghelper.js');

// Tab name fixer (copied from User:Anomie/fix-tab-text.js, target content modified)
/* A simple javascript function to change the text in various tabs at the top of the
 * page. Only tested with the monobook skin.
 */
addOnloadHook(function(){
    var fix=function(id, text){
        var el=document.getElementById(id);
        if(!el) return;
        for(el=el.firstChild; el && el.nodeName!='A'; el=el.nextSibling);
        if(!el) return;
        while(el.firstChild) el.removeChild(el.firstChild);
        el.appendChild(document.createTextNode(text));
    }
 
    /* Add lines as necessary. Use the Firefox DOM inspector or some such to determine
     * the appropriate IDs.
     */
    fix('ca-nstab-user', 'user');
    fix('ca-watch', 'w');
    fix('ca-unwatch', 'uw');
    fix('ca-protect', 'prot');
    fix('ca-move', 'mv');
    fix('ca-history', 'hist');
    fix('ca-talk', 'talk');
    fix('ca-edit', 'edit');
    fix('ca-addsection', '+')
    fix('pt-preferences', 'prefs');
    fix('pt-watchlist', 'watchlist');
    fix('pt-mytalk', 'talk');
    fix('pt-mycontris', 'contribs');
    fix('ca-delete', 'nuke');
});
//end tab name fixer
// Author: [[User:Ladsgroup]]
// License: GPLv3
// Source: https://github.com/Ladsgroup/CheckUserHelper
/*(function ($) {
    function createTable(data) {
        var tbl = document.createElement('table');
        tbl.className = 'wikitable';
        tbl.id = 'SummaryTable';
        var tr = tbl.insertRow();
        tr.appendChild($('<th>').text('User')[0]);
        tr.appendChild($('<th>').text('IP(s)')[0]);
        tr.appendChild($('<th>').text('User Agent(s)')[0]);

        for (user in data) {
            var tr = tbl.insertRow();
            var td = tr.insertCell();
            td.appendChild(document.createTextNode(user));
            if (data[user].ip.length > 1) {
                var ips = document.createElement('ul');
                for (i = 0, len = data[user].ip.length; i < len; i++) {
                    var ip = document.createElement('li');
                    ip.innerHTML = data[user].ip[i];
                    ips.appendChild(ip);
                }
                var td = tr.insertCell();
                td.appendChild(ips);
            } else {
                var td = tr.insertCell();
                td.appendChild(document.createTextNode(data[user].ip[0]));
            }

            if (data[user].ua.length > 1) {
                var uas = document.createElement('ul');
                for (i = 0, len = data[user].ua.length; i < len; i++) {
                    var ua = document.createElement('li');
                    ua.innerHTML = '<code>' + data[user].ua[i] + '</code>';
                    uas.appendChild(ua);
                }
                var td = tr.insertCell();
                td.appendChild(uas);
            } else {
                var td = tr.insertCell();
                var ua = document.createElement('code');
                ua.innerText = data[user].ua[0];
                td.appendChild(ua);
            }
        }
        $('#checkuserform').after(tbl);
    }

    function createTableText(data) {
        var text = "{| class=wikitable\n! User!! IP(s)!! UA(s)\n|-\n";

        for (user in data) {
            text += "|" + user + "||"
            if (data[user].ip.length > 1) {
                for (i = 0, len = data[user].ip.length; i < len; i++) {
                    text += "\n* " + data[user].ip[i];
                }
            } else {
                text += data[user].ip
            }
            text += "\n|"

            if (data[user].ua.length > 1) {
                var uas = document.createElement('ul');
                for (i = 0, len = data[user].ua.length; i < len; i++) {
                    text += "\n* <code>" + data[user].ua[i] + '</code>';
                }
            } else {
                text += "\n* <code>" + data[user].ua[0] + '</code>';
            }

            text += "\n|-\n";
        }
        text += "|}"
        return text;
    }


    function theGadget() {
        var data = {}, hasData = false;
        $('#checkuserresults li').each(function () {
            var user = $(this).children('span').children('.mw-userlink').attr('title');
            if (!user) {
                return;
            }
            var ua = $(this).children('small').children('.mw-checkuser-agent').text();
            if (!ua) {
                var uas = [];
                $(this).children('ol').last().children('li').children('i').each( function() {
                    uas.push($(this).text());
                });
            } else {
                uas = [ua];
            }
            var ip = $(this).children('small').children('a').children('bdi').text();
            if (!ip) {
                var ips = [];
                $(this).children('ol').first().children('li').children('a').each( function() {
                    ips.push($(this).children('bdi').text());
                });
            } else {
                ips = [ip];
            }
            hasData = true;
            if (data[user]) {
                for (ip in ips) {
                    if (data[user].ip.indexOf(ip) === -1) {
                        data[user].ip.push(ip);
                    }
                }
    
                for (ua in uas) {
                    if (data[user].ua.indexOf(ua) === -1) {
                        data[user].ua.push(ua);
                    }
                }
            } else {
                data[user] = { ip: ips, ua: uas };
            }
        });
        if (!hasData) {
            return;
        }
        createTable(data);
        var copyText = createTableText(data);
        mw.loader.using("mediawiki.widgets", function () {
            var dir = (document.getElementsByTagName('html')[0].dir == 'ltr') ? 'left' : 'right';
            var shortened = new mw.widgets.CopyTextLayout({
                align: 'top',
                copyText: copyText,
                successMessage: 'Copied',
                multiline: true,
                failMessage: 'Could not copy'
            });
            shortened.textInput.$element.css(dir, '-9999px');
            shortened.textInput.$element.css('position', 'absolute');
            shortened.buttonWidget.$element.css('position', 'absolute');
            shortened.buttonWidget.$element.css(dir, '0px');
            shortened.buttonWidget.$element.after('<br>');
            $('#SummaryTable').after(shortened.$element);

        });
    };

    if (mw.config.get('wgCanonicalSpecialPageName') == 'CheckUser') {
        theGadget();
    }
})(jQuery);*/

//note: this script MUST be added to the end of your monobook at all times.
//so when you add a new script to the end of your monobook, re-order them so this one is on the bottom.
/* addOnloadHook(function() {
        if(!document.getElementById('wpSummary') || document.getElementById('wpSummary').value != '' || !document.getElementById('wpTextbox1')) return;
        var my_value;
        if(mw.config.get('wgCanonicalNamespace') == 'User_talk') {
                if(mw.config.get('wgPageName').indexOf('/') == -1 && mw.config.get('wgTitle').split('/')[0] != mw.config.get('wgUserName')) 
                        my_value = 'Respond to '+mw.config.get('wgTitle');
                else if(mw.config.get('wgPageName').indexOf('archive') != -1 && mw.config.get('wgTitle').split('/')[0] != mw.config.get('wgUserName')) 
                        my_value = 'Reviving archive';
                else if(mw.config.get('wgPageName').indexOf('archive') != -1 && mw.config.get('wgTitle').split('/')[0] == mw.config.get('wgUserName'))
                        my_value = 'Archiving...';
                else if(mw.config.get('wgPageName').indexOf('/') == -1 && mw.config.get('wgTitle').split('/')[0] == mw.config.get('wgUserName')) 
                        my_value = 'Reply';
                else
                        my_value = 'minor edit';
        } else if(mw.config.get('wgCanonicalNamespace') == 'User') {
                if(mw.config.get('wgTitle').split('/')[0] == mw.config.get('wgUserName'))
                        my_value = 'fixing';
                else
                        my_value = 'fixing a minor mistake';
                
                             //note: leave as "Project". thats how mediawiki outputs it
        } else if(mw.config.get('wgCanonicalNamespace') == 'Project'||wgCanonicalNamespace == 'Project_talk') {
                if((/\w+ for deletion/i).test(mw.config.get('wgTitle')))
                        my_value = 'Add my opinion';
                else if((/requests for adminship/i).test(mw.config.get('wgTitle')))
                        my_value = 'Support';
                else if((/administrator.s noticeboard/i).test(mw.config.get('wgTitle'))) 
                        my_value = 'Reply';
                else if((/administrator intervention against vandalism/i).test(mw.config.get('wgTitle')))
                        my_value = 'Reporting user';
                else
                        my_value = 'Reply';
        } else {
                my_value = 'minor edit';
        }
        document.getElementById('wpSummary').value = my_value;
        document.getElementById('wpSummary').onfocus = function() {
                if(this.value != my_value) return;
                this.selectionStart = 0;
                this.selectionEnd = this.value.length;
        }
});
*/
//*
//
// </nowiki>