Jump to content

User:Nx/monobook.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.
var nx_hfn_strict = true;
importScript('User:Nx/HideFakeNotice.js');
importScript('User:Lupin/recent2.js');

function addSinceTab() {

    // Default number of revisions to check. Set to 0 to use your usual default for a history page.
    // Sensible options might be 300, 500 or 750. Values up to 5000 are valid, but will be quite slow.

    if (!window.defaultdiffs) defaultdiffs=0;

    if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
       do_since_I_last_edited()
    }
    else if (wgCanonicalNamespace != "Special") {
       mw.util.addPortletLink("p-cactions", "/w/index.php?title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=history&gotosince=true" + ((defaultdiffs <= 0) ? "" : "&limit=" + defaultdiffs ), 'since', '', "all changes since your last edit");
    }
}
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 hists=document.getElementById("pagehistory").getElementsByTagName('li');
        for (n=0;n<hists.length;n++) {
            if (getElementsByClassName(hists[n],'*','mw-userlink')[0].innerHTML==wgUserName) {
                histlinks = getElementsByClassName(hists[n],'*','mw-history-histlinks')[0].getElementsByTagName("a")
                if (histlinks.length > 1) {
                    document.location= histlinks[0].href;
                } else {
                    msg.replaceChild(document.createTextNode
                         ("You are the last editor. "),
                         msg.firstChild);
                }
                return;
            }
        }

        msg.replaceChild(document.createTextNode
                         ("You have not edited this page! (recently).  Look at more edits? "),
                         msg.firstChild);

        var lookharderA = document.createElement("A");
        lookharderA.href = wgServer + '/w/index.php?title='+encodeURIComponent(mw.config.get('wgPageName'))+'&action=history&gotosince=true&limit=1000';
        lookharderA.innerHTML = '1000';

        msg.appendChild(lookharderA);

        msg.appendChild(document.createTextNode
                         (" "));

        lookharderA = document.createElement("A");
        lookharderA.href = wgServer + '/w/index.php?title='+encodeURIComponent(mw.config.get('wgPageName'))+'&action=history&gotosince=true&limit=2500';
        lookharderA.innerHTML = '2500';

        msg.appendChild(lookharderA);

        msg.appendChild(document.createTextNode
                         (" "));

        lookharderA = document.createElement("A");
        lookharderA.href = wgServer + '/w/index.php?title='+encodeURIComponent(mw.config.get('wgPageName'))+'&action=history&gotosince=true&limit=5000';
        lookharderA.innerHTML = '5000';

        msg.appendChild(lookharderA);

}

$(addSinceTab);