User:Lyrithya/autodelete.js

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

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

  • Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
  • Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
  • Opera, Konqueror and Safari users can just click the Reload button.
  • Chrome: press Ctrl+F5 or Shift+F5
//<nowiki> 	Autodelete by Spang (User:Spang/autodelete.js) with mods by Olipro, Zombiebaron, etc

var deleteUrl;
function autoDelete() {
	setDeleteForm();
	if (document.getElementById('ca-delete') != undefined) {
		deleteUrl = document.getElementById('ca-delete').firstChild.href;
		var tacos = deleteUrl + '&setdelconfirm=auto&wpReason=';
		
		if (document.cookie.indexOf('lastDelReason') != -1 ) var deleteBox = new Array(12);
		else var deleteBox = new Array(11);

		var csdgh = new Array(4);
		var csdgd = new Array(3);
		var csdai = new Array(5);
		var csdg  = new Array(11);
		var csda  = new Array(6);
		var csdf  = new Array(4);
		var csdu  = new Array(2);
		var csd   = new Array(4);

		csdgh[0] = [tacos + '[[UN:DEL|G6]]: Obviously unnecessary disambiguation page', 'Disambiguation'];
		csdgh[1] = [tacos + '[[UN:DEL|C1]]: Empty category', 'Empty category'];
		csdgh[2] = [tacos + '[[UN:DEL|R2]]: Cross-namespace redirect from mainspace', 'Mainspace redirect'];
		csdgh[3] = [tacos + '[[UN:DEL|R3]]: Implausible redirect', 'Redirect'];

		csdgd[0] = [tacos + '[[UN:DEL|G8]]: Redirect to a deleted or non-existent page', 'Broken redirect'];
		csdgd[1] = [tacos + '[[UN:DEL|G8]]: Subpage of a deleted or non-existent page', 'Subpage of del...'];
		csdgd[2] = [tacos + '[[UN:DEL|G8]]: Talk page of a deleted or non-existent page', 'Orphaned talkp...'];

		csdai[0] = [tacos + '[[UN:DEL|A7]]: Article about a band, singer, musician, or musical ensemble which does not indicate the [[UN:CM|importance or significance]] of the subject', 'Musical group'];
		csdai[1] = [tacos + '[[UN:DEL|A7]]: Article about a company, corporation, organization, or group which does not indicate the [[UN:CM|importance or significance]] of the subject', 'Organisation'];
		csdai[2] = [tacos + '[[UN:DEL|A7]]: Article about an eligible subject which does not indicate the [[UN:CM|importance or significance]] of the subject', 'Subject'];
		csdai[3] = [tacos + '[[UN:DEL|A7]]: Article about a real person which does not indicate the [[UN:CM|importance or significance]] of the subject', 'Person'];
		csdai[4] = [tacos + '[[UN:DEL|A7]]: Article about a web site, blog, web forum, webcomic, podcast, browser game, or similar web content which does not indicate the [[UN:CM|importance or significance]] of the subject', 'Web content'];

		csdg[0] = [tacos + '[[UN:DEL|G1]]: Patent nonsense, meaningless, or incomprehensible', 'Patent non...'];
		csdg[1] = [tacos + '[[UN:DEL|G2]]: Test page', 'Test page'];
		csdg[2] = [tacos + '[[UN:DEL|G3]]: Vandalism', 'Vandalism'];
		csdg[3] = [tacos + '[[UN:DEL|G4]]: Recreation of a page that was deleted per a deletion discussion', 'Recreation ...'];
		csdg[4] = [tacos + '[[UN:DEL|G5]]: Creation by a blocked or banned user in violation of block or ban', 'Created by...'];
		csdg[5] = [csdgh, tacos + '[[UN:DEL|G6]]: Housekeeping and routine (non-controversial) cleanup', 'Cleanup'];
		csdg[6] = [tacos + '[[UN:DEL|G7]]: One author who has requested deletion or blanked the page', 'Author requ...'];
		csdg[7] = [csdgd, tacos + '[[UN:DEL|G8]]: Page dependent on a deleted or nonexistent page', 'Dependent ...'];
		csdg[8] = [tacos + '[[UN:DEL|G10]]: Attack page or negative unsourced BLP', 'Attack page'];
		csdg[9] = [tacos + '[[UN:DEL|G11]]: Unambiguous advertising or promotion', 'Unambigu...'];
		csdg[10] = [tacos + '[[UN:DEL|G12]]: Unambiguous copyright infringement', 'Copyright i...'];

		csda[0] = [tacos + '[[UN:DEL|A1]]: Not enough context to identify article\'s subject', 'No context'];
		csda[1] = [tacos + '[[UN:DEL|A2. Foreign language article that belongs on another Uncyclopedia project', 'Other language'];
		csda[2] = [tacos + '[[UN:DEL|A3]]: Article that has no meaningful, substantive content', 'No content'];
		csda[3] = [tacos + '[[UN:DEL|A5]]: Article that has been moved to another project', 'Moved to ano...'];
		csda[4] = [csdai, tacos + '[[UN:DEL|A7]]: Article about an amorphous blob which does not indicate the [[UN:CM|importance or significance]] of the subject', 'Insignificant'];
		csda[5] = [tacos + '[[UN:DEL|A10]]: Recently created article that duplicates an existing topic', 'Duplicate topic'];

		csdf[0] = [tacos + '[[UN:DEL|F1]]: File redundant to another on Uncyclopedia', 'Redundant file'];
		csdf[1] = [tacos + '[[UN:DEL|F2]]: Corrupt or empty file', 'Empty file'];
		csdf[2] = [tacos + '[[UN:DEL|F5]]: Unused ambiguous file with no ambiguous rationale', 'Unused file'];
		csdf[3] = [tacos + '[[UN:DEL|F10]]: Useless media file', 'Useless file'];

		csdu[0] = [tacos + '[[UN:DEL|U1]]: User request to delete page in own userspace', 'User request'];
		csdu[1] = [tacos + '[[UN:DEL|U2]]: Userpage or subpage of a nonexistent user', 'Userpage of nonexistent user'];

		csd[0] = [csdg, '', 'General',];
		csd[1] = [csda, '', 'Articles'];
		csd[2] = [csdf, '', 'Files'];
		csd[3] = [csdu, '', 'User pages'];

		deleteBox[0] = [deleteUrl  + '&setdelconfirm=auto', 'default'];
		deleteBox[1] = [csd, '', 'CSD'];
		deleteBox[2] = [tacos + 'Fails QA. Read the [[BGBU|beginner\'s guide]] and [[HTBFANJS]].', 'Fails QA'];
		deleteBox[3] = [tacos + 'Wikipedia hasn\'t heard of you. [[UN:CM|Neither have we.]]', 'Vanity'];
		deleteBox[4] = [tacos + '[[UN:DEL|G10]]: [[Uncyclopedia:No cyberbullying|Attack page]] or negative unsourced [[UN:VAIN|BLP]]', 'Cyberbullying'];
		deleteBox[5] = [tacos + '[[VFD|Voted for deletion]]', 'VFD'];
		deleteBox[6] = [tacos + 'Your [[Uncyclopedia:Intensive Care Unit|ICU]] has died. Let me know if you want a copy back.', 'Expired ICU'];
		deleteBox[7] = [tacos + 'Abandoned WIP - [[User talk:Lyrithya|let me know]] if you want a copy back.', 'Abandoned WIP'];
		deleteBox[8] = [tacos + 'Killed by a monthly maintenance tag...', 'Maintenance'];
		deleteBox[9] = [tacos + 'Vigilance.', 'Vigilance'];
		
		if (document.cookie.indexOf('lastDelReason') != -1 ) {
			var cStart = document.cookie.indexOf('lastDelReason') + 14;
			var cEnd = document.cookie.indexOf(';', cStart);
			if (cEnd == -1) cEnd = document.cookie.length;
			lastReason = unescape(document.cookie.substring(cStart, cEnd));
			deleteBox[10] = [tacos + escape(lastReason), 'last: <i>' + lastReason.substr(0,10) + '...</i>'];
			deleteBox[11] = ['javascript:customreason();', 'Custom...'];
		}
		else {
			deleteBox[10] = ['javascript:customreason();', 'Custom...'];
		}

		addCactionsDropdown('ca-delete', deleteBox);
	}
}

function customreason() {
	var delReason=prompt('Enter deletion reason');
	if (delReason != null) {
		document.cookie= 'lastDelReason=' + escape(delReason) + '; path=/';
		window.location='' + deleteUrl + '&setdelconfirm=auto&wpReason=' + escape(delReason);
	}
}

function setDeleteForm() {
	if(window.location.href.indexOf('deltalkpage') != -1){
		var dbody = document.getElementById('bodyContent');
		var alink = dbody.getElementsByTagName('a');
		for(i in alink) {
			if(alink[i].innerHTML == 'del') {
				window.location.href = alink[i].getAttribute('href').toString() + '&setdelconfirm=auto';
				break;
			}
		}
	}
	var deleteconfirm = document.getElementById("deleteconfirm");
	if (!deleteconfirm) return;
    
	var summaryText = queryString('setsummary');
	if (summaryText) {
		var summary = document.getElementsByName("wpSummary")[0];
		if (summary) summary.value = summaryText;
	}

	var setDelConfirm = queryString('setdelconfirm');
	if (setDelConfirm) {
		var btn = document.getElementsByName('wpConfirmB')[0];
		if (deleteconfirm && btn) {
			var tlk = document.getElementById('bodyContent').getElementsByTagName('b')[0];
			if(tlk.innerHTML.indexOf('exists for this page')!= -1 && wgPageName != 'This_page_does_not_exist') {
				var curatr = document.getElementById('deleteconfirm').getAttribute('action').toString();
				curatr += '&deltalkpage=true';
				document.getElementById('deleteconfirm').setAttribute('action', curatr);
			}
			if(queryString('doclose') == 'true') {
				form = document.getElementById('deleteconfirm');
				formstr = form.getAttribute('action');
				formstr += '&doclose=true';
				form.setAttribute('action', formstr);
			}
			btn.textContent += " (auto clicking...)";
			btn.click();
		}
	document.getElementById('ca-delete').firstChild.innerHTML = 'Delete ▾';
	}
};

function queryString(p) {
	var re = RegExp('[&?]' + p + '=([^&]*)');
	var matches;

	if (matches = re.exec(document.location)) {
		try { 
			return decodeURI(matches[1]);
		} catch (e) {}
	}
  	return null;
};

YAHOO.util.Event.onContentReady('p-cactions', autoDelete);


//</nowiki>