User:Abigor/monobook.js

From Wikimedia Incubator

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
//Written and maintained by [[User:Mike.lifeguard]]
function deletemods(){
	if (wgAction == "delete") {
		var wpReason = document.getElementById("wpReason");
		if (!wpReason) return;
		var regexp = /(content was|page was empty|content before blanking was)/i;
		if (regexp.test(wpReason.value)){
			wpReason.value = "";
		}
	}
}
$(deletemods);


// Outline for an automatic delete link generator.
// Not highly tested. Started by Splarka @ test.wikipedia
// Written for & maintained by Mike_lifeguard @ en.wikibooks
//GO IF contribs or log or newpages or [article AND (submit|view|purge)]
if ("Contributions Whatlinkshere Log Prefixindex Newpages".indexOf(wgCanonicalSpecialPageName) != -1 || (wgIsArticle == true && (wgAction == "submit" || wgAction == "view" || wgAction == "purge")))
 $(document).ready(function() {
    addPortletLink('p-cactions', 'javascript:deleteLinkify()', 'AutoDelete', 'ca-dellink', 'generate deletion links');
});
 
function deleteLinkify() {
    var reason = prompt('Enter default delete reason', 'per [[COM:SPEEDY]]');
    if (!reason) return;
 
    var arp = wgServer + wgArticlePath.replace(/\$1/, '');
    $('#bodyContent a').each(function() {
        if (this.href.indexOf(arp) == 0 && this.href.indexOf('action=delete') == -1 && this.href.indexOf('/Special:') == -1) {
            this.href += '?action=delete&submitdelete=true&deletetalkalso=true&wpReason=' + encodeURIComponent(reason);
            this.innerHTML += ' (delete)';
        }
    });
 
}
if (queryString('submitdelete') == 'true') $(document).ready(function() {
    var sub = (document.getElementById('wpConfirmB')) ? document.getElementById('wpConfirmB') : document.getElementById('mw-filedelete-submit')
    if (document.getElementById('ca-talk').className.indexOf('new') == -1 && queryString('deletetalkalso') == 'true' && (wgNamespaceNumber % 2 == 0)) {
        //if the talk tab is redlinked and this is the first time 'round AND this is not a talk page then:
        sub.action += '&deletetalk=true&wpReason=' + queryString('wpReason');
    }
    sub.click();
})
 
 if (wgAction == 'delete' && queryString('deletetalk') == 'true') $(document).ready(function() {
    var url = document.getElementById('ca-talk').getElementsByTagName('a')[0].href + '?action=delete&submitdelete=true&wpReason=' + queryString('wpReason');
    document.location.href = url;
})
 
 function queryString(p) {
    var re = RegExp('[&?]' + p + '=([^&]*)');
    var matches;
    if (matches = re.exec(document.location)) {
        try {
            return decodeURI(matches[1]);
        } catch(e) {
            }
    }
    return null;
}