Jump to content

User:Waldyrious/modern.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.
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 (mw.config.get('wgCanonicalNamespace') != "Special") {
       addPortletLink("p-cactions", mw.config.get('wgScript') + "?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");
        if( !csub || !msg ) return;

        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++) {
            var userlink = getElementsByClassName(hists[n],'*','mw-userlink');
            if (userlink.length > 0 && userlink[0].innerHTML==mw.config.get('wgUserName')) {
                var histlinks = getElementsByClassName(hists[n],'*','mw-history-histlinks');
                if (histlinks.length > 0) {
                    var histlinkas = histlinks[0].getElementsByTagName("a");
                    if (histlinkas.length > 1) {
                        document.location= histlinkas[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 = mw.config.get('wgScript') + '?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 = mw.config.get('wgScript') + '?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 = mw.config.get('wgScript') + '?title='+encodeURIComponent(mw.config.get('wgPageName'))+'&action=history&gotosince=true&limit=5000';
        lookharderA.innerHTML = '5000';
 
        msg.appendChild(lookharderA);
 
}
 
addOnloadHook(addSinceTab);