User:Ex13/monobook.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// 
mw.loader.load('https://commons.wikimedia.org/w/index.php?title=User:Suradnik13/extraeditbuttons.js'
             + '&action=raw&ctype=text/javascript');

// Copied from http://en.wikipedia.org/wiki/User:Bradv/AjaxPatrolLinks.js
function CVU_ajaxPatrolLinks() {
    var a = document.evaluate('//div[@class="patrollink"]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;
    if (a) {
        var div = a.parentNode;
        var url = a.href;
        a.onclick = function (event) {
            var aj = sajax_init_object();
            if (aj) {
                while (div.firstChild) { div.removeChild(div.firstChild) };
                div.appendChild(document.createTextNode('[Označavam za pregledano...]'));
                aj.onreadystatechange = function () {
                    if (aj.readyState == 4 && aj.status == 200) {
                        while (div.firstChild) { div.removeChild(div.firstChild) };
                        div.appendChild(document.createTextNode('[Pregledano]'));
                        aj.onreadystatechange = null;
                        if (CVU_ajaxPatrolLinks_closeafter == true){
                            window.close(); self.close();
                        }
                    }
                }                
                aj.open("GET", url, true);
                aj.send(null);
                return false;
            }
        }
    }
    var b = document.evaluate('//span[@class="patrollink"]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;
    if (b) {
        var div = b.parentNode;
        var url = b.href;
        b.onclick = function (event) {
            var bj = sajax_init_object();
            if (bj) {
                while (div.firstChild) { div.removeChild(div.firstChild) };
                div.appendChild(document.createTextNode('[Označavam za pregledano...]'));
                bj.onreadystatechange = function () {
                    if (bj.readyState == 4 && bj.status == 200) {
                        while (div.firstChild) { div.removeChild(div.firstChild) };
                        div.appendChild(document.createTextNode('[Pregledano]'));
                        bj.onreadystatechange = null;
                        if (CVU_ajaxPatrolLinks_closeafter == true){
                            window.close(); self.close();
                        }
                    }
                }                
                bj.open("GET", url, true);
                bj.send(null);
                return false;
            }
        }
    }
}
$(CVU_ajaxPatrolLinks);