User:Nathanm mn/monobook.js

Source: 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.
//
// From User:Lunchboxhero/monobook.js
//

var magicURL = "http://www.amazon.com/gp/search?ie=UTF8&field-isbn=MAGICNUMBER&tag=wikipedia08-20";
importScript('User:Lunchboxhero/externISBN.js');


//
//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'); }

function KateLink()
  {
    // use the "edit this page" tab to get user name
    var user = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
    // cut everything up to "title=" from the start and everything past "&action=edit" from the end
    user = user.substring(user.indexOf('title=') + 6, user.lastIndexOf('&action=edit'));
    user = user.substring(user.indexOf(':') + 1);
  
    var li = document.createElement( 'li' );
    li.id = 'pt-kate';
  
    var a = document.createElement( 'a' );
    a.appendChild( document.createTextNode( 'count' ) ); // eh, the css makes the text lowercase
    a.href = 'http://en.wikipedia.org/wiki/User:Interiot/Tool2/code.js?username=' + user;

    li.appendChild( a );
  
    if ( ! gsKateInsertBefore ) // append to end (right) of list
    {
       document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
    }
    else
    {
        var before = document.getElementById( gsKateInsertBefore );
        before.appendChild( li, before );
    }
  }

//add this if to Main() or load function
  if (document.title.indexOf("User") != -1)
    KateLink(); //count menu option on user pages

//
// add navigation popups
// [[User:Lupin/popups.js]]
//

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');

//
// Wikipedia:WikiProject User scripts/Scripts/Show last diff
//

$( function () {
  if (mw.config.get('wgCanonicalNamespace') != "Special") {
    mw.util.addPortletLink('p-cactions', mw.config.get('wgServer') + '/w/index.php?title=' + mw.config.get('wgPageName') + '&diff=cur&oldid=prev', 'last', 'ca-last', 'Show most recent diff');
  }
});

//
// Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited
//

function addSinceTab() {
    if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
       do_since_I_last_edited()
    }
    else if (mw.config.get('wgCanonicalNamespace') != "Special") {
       mw.util.addPortletLink("p-cactions", "/w/index.php?title="+mw.config.get('wgPageName')+"&action=history&gotosince=true", 'Changes since I last edited', '', "Changes since I last edited");
    }
}
function do_since_I_last_edited() {
        var csub=document.getElementById("contentSub");
        var msg=document.createElement("p");
        msg.appendChild(document.createTextNode
                        ("Parsing history... please wait..."));
        msg.className="error";
        csub.insertBefore(msg, csub.firstChild)

        var username=document.getElementById("pt-userpage").textContent;
        var hists=document.getElementById("pagehistory").getElementsByTagName('li');
        for (n=0;n<hists.length;n++) {
            if (hists[n].getElementsByTagName("span")[0].getElementsByTagName('a')[0].textContent==username) {
                document.location=hists[n].childNodes[1].href; 
                return;
            }
        }

        msg.replaceChild(document.createTextNode
                         ("You have not edited this page! (recently)"),
                         msg.firstChild);
}

$(addSinceTab);

//
// Wikipedia:WikiProject User scripts/Scripts/Duplicate tabs at bottom
// depends on CSS in [[User:Nathanm mn/monobook.css]]
//

$(function () {
    var tabs = document.getElementById('p-cactions').cloneNode(true);
    tabs.id = 'mytabs';
    var listitems = tabs.getElementsByTagName('LI');
    for (i=0;i<listitems.length;i++) {
        if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
    }

    content = document.getElementById("content");    // Find the content div
    content.parentNode.insertBefore(tabs, content.nextSibling);    // Place tab list right after content div
});