User:GeorgeMoney/scripts/durescript.js

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.
//<pre><nowiki>

// ------- HELPER FUNCTIONS ---------

//    --- ADD VARIOUS LINKS ----
function addToolboxLink(url, name, id){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, url, name, id);
}
// 
function addTopLink(url, name, id){
    var personal = document.getElementById('p-personal').getElementsByTagName('ul')[0];
    addlilink(personal, url, name, id);
}
// 
function addNavLink(url, name, id){
    var navigation = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
    addlilink(navigation, url, name, id);
}
// 

function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    return addlilink(tabs, url, name, id, title, key);
}

//

//      ------ MORE MAJOR LINKAGE -----
function addLink(where, url, name, id, title, key, after){
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
    //
    //* url is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //
    //* name is what will appear as the name of the button.
    //
    //* id is the id of the button; it's best to define one.  
    //   Use a prefix to make sure its unique. Optional.
    //
    //* title is the tooltip title that gives a longer description 
    //   of the button; if you define a accesskey, mention it here. Optional.
    //
    //* key is the char you want for the accesskey. Optional.
    //
    //* after is the id of the button you want to follow this one. Optional.
    //
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        tabs.appendChild(li);
    }
    if(id) {
        if(key && title) { ta[id] = [key, title]; }
        else if(key) { ta[id] = [key, '']; }
        else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
    
// 

// ------------- LINKAGE ----------------

function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    if(id)
    {
        if(key && title)
        {
            ta[id] = [key, title];
        }
        else if(key)
        {
            ta[id] = [key, ''];
        }
        else if(title)
        {
            ta[id] = ['', title];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}

// 

// 

// --------------------Interiot's javascript edit counter
if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
  mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); }

//-----------------Admin-like RC Patrol tools

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:VoA/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//[[Category:RC scripted users]]

// -------------------------Replace txt
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/replacetxt.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//

// --------------------Log tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Sleeper/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');


// ------------ADD VARIOUS LINKS TO NAV
$(function(){addNavLink('http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=newusers&user=&page=', 'New user log');});

//---------- WELCOMING

function NUPatrol()
{
        if (    ( window.location.href.indexOf( 'Special%3ALog&type=newusers' ) == -1 ) &&
                        ( window.location.href.indexOf( 'Special:Log/newusers'        ) == -1 )  )
        return; // make more robust???

        var items, item, i, links, user, name, talk, contribs, insertLoc, link;

        items = document.getElementById( 'bodyContent' ).getElementsByTagName( 'ul' )[ 0 ].getElementsByTagName( 'li' );

        function NewLink( txt, url, plainlinks, linkColor )
        {       var a = document.createElement( 'a' );
                        a.appendChild( document.createTextNode( txt ) );
                        a.href = url;
                if ( plainlinks ) a.className = 'plainlinks';
                if ( linkColor )
                {       if ( typeof linkColor == "string" )
                                        a.style.color = linkColor;
                }
                return a;
        }

        for ( i = 0; i < items.length; i++ )
        {
                item = items[ i ];
                
                links = item.getElementsByTagName( 'a' );

                        user = links[ 0 ]; name = user.firstChild.nodeValue;
                        talk = links[ 1 ]; talk.firstChild.nodeValue = '████'; // lowercase 'Talk' for consistency

                insertLoc = user.nextSibling; // ' newusers '

                item.insertBefore( document.createTextNode( ' ( ' ), insertLoc );

                item.insertBefore( talk, insertLoc );
                item.insertBefore( document.createTextNode( ', ' ), insertLoc );

                item.insertBefore( NewLink( 'blocks', '/w/index.php?title=Special%3ALog&type=block&page=User%3A' + name, true, '#002bb8' ), insertLoc );
                item.insertBefore( document.createTextNode( ', ' ), insertLoc );

                item.insertBefore( NewLink( '[report]', 'javascript:AIVandal("' + name + '")', true, 'red' ), insertLoc );
                item.insertBefore( document.createTextNode( ', ' ), insertLoc );

                item.insertBefore( NewLink( '[welcome]', '/w/index.php?title=User_talk:' + name + '&action=edit&autoclick=wpSave&autosummary=Welcome!&preload=User:Dure/W&editintro=Template%3AThisisnotatemplate&section=new&create=Welcome', true, 'green' ), insertLoc );

                item.insertBefore( document.createTextNode( ' )' ), insertLoc );

                item.removeChild( insertLoc.nextSibling ); // should remove the span
                item.removeChild( insertLoc ); // should remove ' newusers ' text
        }
}
if ( window.addEventListener ) window.addEventListener( 'load', NUPatrol, false );
else if ( window.attachEvent ) window.attachEvent( 'onload', NUPatrol );


//

//</nowiki></pre>