User:Royalguard11/csd.js

// //When you install this script, you will also need to install cookie functions: //User:GeorgeMoney/UserScripts/helpers/all //_-_-_-_-_-_-_-_-_-_CSD-_-_-_-_ if(window.location.href.indexOf('speedydel') != -1 && window.location.href.indexOf('action=delete') != -1) { addOnloadHook(function { doeasycsd; }); }

//The accesskey to use on the tab var tab_shortcut = "a";

//the criteria to not show "content was" var nocontent = "A2|A8|G10|U1";

//Delete the talkpage along with the main page var deletetalk = true;

//Namespaces to not delete the talkpage of var nodeletetalkNS = "User|Help";

//Image deletion extention var image_use = true;

//The summary to use when removing from article var image_sum = "Commenting out Image:$1 because it has been deleted";

//The button to click when commenting out image var image_click = 'wpSave';

//If image not found on page, ask to skip it, or just skip it period var image_asktoskip =  false;

//Article wikilink removal extention var article_use = false;

//Summary to use when removing wikilink var article_sum = "Removing wikilink to $1 because it was deleted";

//The button to click when removing wikilink var article_click = 'wpSave';

//The namespaces to ask you if you want to remove link from it (namespace of the page deleted) var article_remove_ns = ""; //"User|Talk|Wikipedia"; //if is blank, it means main namespace

//If link not found on page, ask to skip it var article_asktoskip =  false;

//namespaces to not remove link (namespace of page where the link is being removed from) var article_noremove_ns = "User|Wikipedia|User_talk|Image|Category|Category_talk";

//To open the creator's talk page Please set this to false it is experimental var useopentp = false;

//Default summary for criterias. $1 means where the criteria name will go //This is NOT what is used if you leave the inputbox blank. See above //This is called from the function defaultsum var thedefaultsum = "Per Criteria for Speedy Deletion, $1";

//The default criteria to use if the inputbox is blank //Note: This is NOT the defaultsum. The defaultsum is the summary to use as default for criterias that you haven't set a special summary //This is ONLY used if the inputbox is blank, or you entered a summary that is not defined //This just calls the summary for whatever value you put in the var var defaultcrit = "I4";

var msgs = { //This is all the messages used in the script

//Extra summaries that you will type into the inputbox. so if you type "extra1" it will go to the value of "extra1" //Make sure there is a comma at the end of every line //Note: The extra summaries are case sensitive. The WP:CSD ones are not extra1: "Extra summary",

//All the criterias. Replace defualtsum('foo') with "yoursummary". so   G1: defaultsum('G1'),  becomes   G1: "yoursummary", G1: "Per G1, This article or other page provides no meaningful content or history, and/or the text is unsalvageably incoherent. It is patent nonsense.", G2: "Per G2, Test pages", G3: "Per G3, Pure vandalism; this includes redirects created during cleanup of page move vandalism.", G4: "Per G4, It is reposted content that was deleted as a result of an articles for deletion (or another XfD) discussion.", G5: "Per G5, Page created by banned users while they were banned.", G6: "Per G6, housekeeping", G7: "Per G7, This page was mistakenly created, no one other than its original author has made substantial edits, and he or she requests its deletion or has blanked the page.", G8: "Per G8, Talk pages of pages that do not exist", G9: defaultsum('G9'), G10: "Per CSD G10 - Attack page - Please don't post attacks.", G11: 'Per CSD G11 - Advertising - Please see our guidelines.', G12: 'Per CSD G12 - Copyright infringement, Please see our copyright policy. Find answers to common questions at our Copyright FAQ and Contributing FAQ.',

A1: 'CSD A1 - Very short articles providing little or no context', A2: 'per CSD A2 - Foreign language article, Foreign language articles that exist on another Wikimedia project are eligible for speedy deletion', A3: "Per CSD A3 - No content whatsoever, Any article consisting only of links elsewhere, a rephrasing of the title, and/or attempts to correspond with the person or group named by its title", A4: "Per CSD A3 - No content whatsoever, Any article consisting only of links elsewhere, a rephrasing of the title, and/or attempts to correspond with the person or group named by its title", A5: "Per A5, Transwikied articles", A6: "Per CSD G10 - Attack page - Please don't post attacks.", A7: "Per CSD A7 - Unremarkable people, groups, companies and web content that does not assert the importance or significance of its subject.", A8: 'Per CSD G12 - Copyright infringement, Please see our copyright policy. Find answers to common questions at our Copyright FAQ and Contributing FAQ.',

R1: "Per R1, Redirects to non-existent pages", R2: "Per R2, redirect to userspace from mainspace", R3: "Per R3, implausible typo",

I1: "Per I1, Redundant image", I2: "Per I2, Corrupt or empty image", I3: "Per I3, Improper license uploaded after May 19/05", I4: "Per I4, Lack of licensing information for 7 days", I5: "Per I5, Unused unfree copyrighted images", I6: "Per I6, Missing fair-use rationale", I7: "Per I7, Invalid fair-use claim", I8: "Per I8, Images available as bit-for-bit identical copies on the Wikimedia Commons",

C1: "Per C1, It is a category that has no items whatsoever in it, it has been empty for at least four days, and its only content has been linked to parent categories.", C2: "Per C2, Empty category that qualifies for Speedy renaming", C3: "Per C3, This category is used solely by a template that has been deleted",

U1: "Per U1, User page or user subpage requested to be deleted by the user who created it.", U2: "Per U2, it is a userpage of a non-existent user.", U3: "Per U3, Galleries in the user space which consist mostly of fair use images.",

T1: "Per T1, It is a template that is divisive and inflammatory",

P1: "Per P1, portal qualifies as speedy under article criteria", P2: "Per P2, It is a portal based on a topic for which there is not a non-stub header article, and at least three non-stub articles detailing subject matter that would be appropriate to discuss under the title of that portal.",

z: "Closing Prod that is older than 5 days.",

dummy: 'this is a dummy entry to break the comma' };

if(/*document.getElementById('ca-delete')*/wgCanonicalNamespace != 'Special') { $(function { var tbsd = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlilink(tbsd, 'javascript:doeasycsd', 'CSD', 'ca-speedy', 'CSD', tab_shortcut); }); }

var nocontent = nocontent.split('|'); var nodeletetalkNS = nodeletetalkNS.split('|'); var article_remove_ns = article_remove_ns.split('|'); var article_noremove_ns = article_noremove_ns.split('|');

var myPageName = wgPageName.replace(/_/g, ' ');

//alert(msgs.thedefaultsum + msgs.extra1); function defaultsum(h) { var f = thedefaultsum.replace(/\$1/g, h); return f; } function doeasycsd { var alm = true; if(window.location.href.indexOf('useurl') == -1) { var otherurlstf = ""; var useprompt = true; if(document.getElementById('delete')) { useprompt = false; var md = document.getElementById('delete'); var linksf = md.getElementsByTagName('a'); //			alert("DEBUG: Over the next "+(linksf.length+1)+" alerts, you will see the urls of all the links in the speedy tag"); for(var i=0; i<linksf.length; i++) { var ll = linksf[i]; //				alert("DEBUG: Link #"+(i+1)+": href: "+ll.href+"\ninnerHTML: "+ll.innerHTML); if(ll.href.indexOf("Wikipedia:Criteria_for_speedy_deletion") != -1||ll.href.indexOf("WP:CSD") != -1) { var usecrit = ll.href.split('#'); if(usecrit[1] == undefined) usecrit = false; else { //					alert("DEBUG: WP:CSD criteria was found on link #"+(i+1)+": href: "+ll.href); usecrit = usecrit[1]; break; }		} else var usecrit = false; }	if(usecrit === false) { useprompt = true; //				alert("DEBUG: Speedy criteria not found in speedy tag"); } else { var r = prompt('A speedy deletion criteria, "'+usecrit+'" was found on this page\nTo delete the page using that criteria, leave this textbox blank and press ok\nTo use a different criteria, enter it in the textbox and press ok'); if(r==null) { alert("Action canceled"); return; } if(r=="") r = usecrit; } }

if(useprompt) var r = prompt('What speedy criteria?'); if(r == null) { alert('Action canceled'); return; } else if(r=="s") { var re = prompt('What extra summary?'); if(re == null) { alert('Action canceled'); return; } var usesum = re; var lr = "spec"; var alm = false; } else if(r=="h") { var re = prompt('What extra summary to use \nwithout showing "content was"?'); if(re == null) { alert('Action canceled'); return; } var usesum = re; var lr = "specnc"; var alm = false; }

for(var i = 0; i<article_remove_ns.length; i++) { var nf = article_remove_ns[i]; if(wgCanonicalNamespace == nf) { var dolink = true; break; } else { var dolink = false; } } if(window.location.href.indexOf('?') != -1) var charuse = '&'; else var charuse = '?'; if(wgCanonicalNamespace == "Image"&&image_use) { if(confirm("Would you also like to remove all the file links from this image?")) { var gop = window.location.href.replace('action=delete', '')+charuse+'&imageopen=true'; otherurlstf = "&ext_dorem_img=true&ext_dorem_goto="+escape(gop); }} else if(dolink && article_use) { if(confirm("Would you also like to remove all the wikilinks pointing to this page?")) { var nop = unescape(window.location.href).replace(wgPageName, 'Special:Whatlinkshere/'+wgPageName)+charuse+'&linkopen=true'; otherurlstf = "&ext_dorem_art=true&ext_dorem_goto="+escape(nop); }} } else { var r = gvo('delcrit'); } if(r.indexOf('s|') == 0) { var usesum = r.replace('s|', ''); var lr = "spec"; var alm = false; } else if(r.indexOf('h|') == 0) { var usesum = r.replace('h|', ''); var lr = "specnc"; var alm = false; }

if(r!=''&&alm) { var cr = r.toUpperCase; eval('if(msgs.'+cr+' != undefined) { var usesum = msgs.'+cr+'; var lr = \+cr+'\'; } else if(msgs.'+r+' != undefined) { var usesum = msgs.'+r+'; var lr = \+r+'\'; } else { var usesum = msgs.'+defaultcrit+'; var lr = defaultcrit; }'); }

if(window.location.href.indexOf('speedydel') == -1) { if(lr == "spec") { lr = "s|"+usesum; } if(lr == "specnc") { lr = "h|"+usesum; } if(wgNamespaceNumber % 2 == 0 && deletetalk) var urldeletetalk = "&deletetalk="+escape(((wgCanonicalNamespace != '')?wgCanonicalNamespace+'_talk:':'Talk:')+wgTitle); else var urldeletetalk = ""; window.location.href = (document.getElementById('ca-delete').firstChild.href+'&speedydel=true&delcrit='+escape(lr)+'&useurl=true'+urldeletetalk+otherurlstf); if(useopentp) { window.open(document.getElementById('ca-history').firstChild.href+'&opentalk=true&limit=1'); window.open(document.getElementById('ca-history').firstChild.href+'&opentalk=true&opencontribs=true&limit=1'); } } else if(window.location.href.indexOf('speedydel') != -1) { var mydel = document.getElementById('wpReason'); if(mydel) { var olddelsum = mydel.value; for(var i = 0; i<nocontent.length; i++) { var nc = nocontent[i]; if(lr == nc||lr=="specnc") { var donotc = true; break; } else { var donotc = false; }       }        if(donotc||mydel.value=="") { var olddelsum = ""; } else { var olddelsum = "- "+olddelsum; } var newdelsum = usesum+" "+olddelsum; document.getElementById('wpReason').value = newdelsum; var inputs = document.getElementsByTagName('input'); for(var i = 0; i<nodeletetalkNS.length; i++) { var nd = nodeletetalkNS[i]; if(wgCanonicalNamespace == nd) { var donod = false; break; } else { var donod = true; }       }	if(window.location.href.indexOf('deletetalk') != -1&&deletetalk&&donod) { var wop = window.location.href.split('&deletetalk=')[0].replace(wgPageName, gvo('deletetalk'));//+'&closewindow=true'; createCookie('delscript_goto', escape(wop)); }	if(window.location.href.indexOf('ext_dorem_img=true') != -1) { var gop = gvo('ext_dorem_goto'); createCookie('delscript_goto', escape(gop)); createCookie('delscript_imagepage', escape(wgTitle)); }	if(window.location.href.indexOf('ext_dorem_art=true') != -1) { var nop = gvo('ext_dorem_goto'); createCookie('delscript_goto', escape(nop)); createCookie('delscript_linkpage', escape(myPageName)); }   for (i=0; i<inputs.length; i++) { if (inputs[i].name == 'wpConfirmB') { inputs[i].click; }	}	}   }

}

if(readCookie('delscript_goto') != null) { var cookie = unescape(readCookie('delscript_goto')); eraseCookie('delscript_goto'); window.location.href = (cookie); }

if(window.location.href.indexOf('imageopen=true') != -1) { var togoto = ""; $(function {

if(readCookie('delscript_doimg') == null) { var ok = true; if(ok) { createCookie('delscript_image_ok', 0); var main1 = document.getElementById('filelinks'); if(main1) { var main2 = main1.nextSibling.nextSibling; if(main2) { var main3 = main2.nextSibling; if(main3) { var main4 = main3.nextSibling.nextSibling; if(main4) { if(main2.tagName == "P" && main3.id == "linkstoimage" && main4.tagName == "UL") { var lis = main4.getElementsByTagName('li'); for(var i = 0; i < lis.length; i++) { var hr = lis[i].firstChild.href; var realpg = unescape(readCookie('delscript_imagepage')); var wnopen = hr+'?action=edit&remimage=true&image_to_delete='+escape(realpg); //window.open(wnopen); togoto += "|"+wnopen; }			togoto += "|"+window.location.href.split('&imageopen=true')[0]; createCookie('delscript_togoto', escape(togoto.substr(1))); createCookie('delscript_doimg', 'yes'); eraseCookie('delscript_oktogoto'); location.reload; }	}}}} }} else { eraseCookie('delscript_doimg'); createCookie('delscript_numgoto', '0'); var oldnum = parseInt(readCookie('delscript_numgoto')); var newnum = oldnum + 1; createCookie('delscript_numgoto', newnum); var myarr = unescape(readCookie('delscript_togoto')).split('|'); //alert('doimg. togoto is set, and it is: '+myarr+'; numgoto is: '+readCookie('delscript_numgoto')+' newnum: '+newnum+'; oldnum: '+oldnum); window.location.href = myarr[oldnum]; } }); }

if(window.location.href.indexOf('linkopen=true') != -1) { var togoto = ""; var templategoto = ""; $(function {	if(readCookie('delscript_doart') == null) {	var ok = true;	if(ok) {	if(readCookie('delscript_latergoto') != null) { togoto = unescape(readCookie('delscript_latergoto')); eraseCookie('delscript_latergoto'); var notemplate = true; }	else { 	var notemplate = false;	var lis = document.getElementById('bodyContent').getElementsByTagName('ul')[0].getElementsByTagName('li');	for(var i = 0; i < lis.length; i++) {		var hr = lis[i].firstChild;		if(!hr) continue;		hr = hr.href;		if(hr.indexOf('&redirect=no') != -1) var isRedir = true;		else var isRedir = false;		var page_ns = hr.substr(('http://'+location.host).length);		page_ns = page_ns.split(':')[0];		if(page_ns == hr) page_ns = "";		else {		page_ns = page_ns.split('/');		page_ns = page_ns[(page_ns.length - 1)];		}		for(var j=0; j<article_noremove_ns.length; j++) {			var nk = article_noremove_ns[j];			if(page_ns == nk) {				var oktocont = false; break; } else var oktocont = true; }		if(!oktocont) continue; var realpg = unescape(readCookie('delscript_linkpage')); if(!isRedir) var wnopen = hr+'?&action=edit&remlink=true&link_to_delete='+escape(realpg); else var wnopen = hr+'?&action=delete&speedydel=true&delcrit=r1&useurl=true'; if(page_ns == "Template") templategoto += "|"+wnopen; else togoto += "|"+wnopen; }	togoto += "|"+window.location.href.split('&linkopen=true')[0]; }	if(templategoto != '') templategoto += "|"+window.location.href; if(togoto.indexOf('|') == 0) togoto = togoto.substr(1); if(templategoto.indexOf('|') == 0) templategoto = templategoto.substr(1); if(notemplate) templategoto = ""; var mygoto = (templategoto != '')?templategoto:togoto; if(mygoto == templategoto) createCookie('delscript_latergoto', escape(togoto)); createCookie('delscript_togoto', escape(mygoto)); createCookie('delscript_doart', 'yes'); eraseCookie('delscript_oktogoto'); location.reload; }} else { eraseCookie('delscript_doart'); createCookie('delscript_numgoto', '0'); var oldnum = parseInt(readCookie('delscript_numgoto')); var newnum = oldnum + 1; createCookie('delscript_numgoto', newnum); var myarr = unescape(readCookie('delscript_togoto')).split('|'); //alert('doimg. togoto is set, and it is: '+myarr+'; numgoto is: '+readCookie('delscript_numgoto')+' newnum: '+newnum+'; oldnum: '+oldnum); window.location.href = myarr[oldnum]; } }); }

if(window.location.href.indexOf('remimage=true') != -1 && window.location.href.indexOf('action=edit') != -1) { $(function {	var oldtext = document.getElementById('wpTextbox1').value;	var txt = document.getElementById('wpTextbox1');	var img = gvo('image_to_delete');	var regimg = img.replace(/\./g, '\\.').replace(/\*/g, '\\*').replace(/\//g, '\\/')					.replace(/[ _]/g, '[ _]')	var reg1 = new RegExp('\\[\\[[Ii]mage:\\s*'+regimg+'\\s*(\\|.*?\\]|\\])\\]', "ig");	var rpl1 = ;	var reg2 = new RegExp('([Ii]mage:)?'+regimg, "ig");	var rpl2 = ;	var newtext = oldtext.replace(reg1, rpl1);	var is_same = (newtext == oldtext);	if(is_same) newtext = oldtext.replace(reg2, rpl2);	txt.value = newtext;	document.getElementById('wpSummary').value = image_sum.replace(/\$1/g, img);	document.getElementById('wpMinoredit').checked = "checked";	document.getElementById('wpWatchthis').checked = "";	if(is_same&&image_asktoskip) {		var oktoclick = confirm("The image, "+img+" was not found on this page \n probably due to it being in an odd format \n press ok to go and remove it yourself,\n or cancel to just abort this edit and move on to the next");	} else var oktoclick = false;	createCookie('delscript_oktogoto', 'yes');	if(!oktoclick) document.getElementById(image_click).click;		//if(image_click == "wpSave") window.close; }); }

if(window.location.href.indexOf('remlink=true') != -1 && window.location.href.indexOf('action=edit') != -1) { $(function {	var oldtext = document.getElementById('wpTextbox1').value;	var txt = document.getElementById('wpTextbox1');	var lnk = gvo('link_to_delete');	var reglnk = lnk.replace(/\./g, '\\.').replace(/\*/g, '\\*').replace(/\//g, '\\/')					.replace(/[ _]/g, '[ _]')	var reg = new RegExp('\\[\\['+reglnk+'\\|?(.*?)\\]\\]', "ig");	newtext = oldtext.replace(reg, '');	newtext = newtext.replace(/\{\{D\:\}\}/g, lnk);	newtext = newtext.replace(/\{\{D:(.*?)\}\}/g, '$1');	txt.value = newtext;	document.getElementById('wpSummary').value = article_sum.replace(/\$1/g, lnk);	document.getElementById('wpMinoredit').checked = "checked";	document.getElementById('wpWatchthis').checked = "";	if(newtext == oldtext&&article_asktoskip) {		var oktoclick = confirm("The link, "+lnk+" was not found on this page \n probably due to it being in an odd format \n press ok to go and remove it yourself,\n or cancel to just abort this edit and move on to the next"); } else var oktoclick = false; createCookie('delscript_oktogoto', 'yes'); if(!oktoclick) document.getElementById(article_click).click; //if(image_click == "wpSave") window.close; }); }

if(readCookie('delscript_togoto') != null&&readCookie('delscript_oktogoto') != null) { //		alert('Togoto is set, and it is: '+readCookie('delscript_togoto')+'; numgoto is: '+readCookie('delscript_numgoto')); var oldnum = parseInt(readCookie('delscript_numgoto')); var newnum = oldnum + 1; createCookie('delscript_numgoto', newnum); var myarr = unescape(readCookie('delscript_togoto')).split('|'); if(newnum == myarr.length) { eraseCookie('delscript_togoto'); eraseCookie('delscript_numgoto'); } eraseCookie('delscript_oktogoto'); window.location.href = myarr[oldnum]; }

if(useopentp && window.location.href.indexOf('opentalk=true') != -1 && window.location.href.indexOf('action=history') != -1) { $(function { for(var i=0; i<document.links.length; i++) { var l = document.links[i]; if(l.innerHTML.indexOf('Earliest') == 0) { window.location.href = (l.href+'&opentalk=true'); return; } else { foundit = false; } } if(!foundit) { for(var i=0; i<document.getElementsByTagName('form').length; i++){ var k = document.getElementsByTagName('form')[i]; if(k.method=="get" && k.firstChild.name == "title" && k.firstChild.type == "hidden") { var lastli = k.getElementsByTagName('li')[(k.getElementsByTagName('li').length - 1)]; var g = lastli.getElementsByTagName('span')[0].getElementsByTagName('a'); for(var j = 0; j<g.length; j++) { var f = g[j]; if(f.firstChild.data == "Talk") { var go = f.href; } else if(f.firstChild.data == "contribs"&&window.location.href.indexOf('opencontribs=true') != -1) { var wo = f.href; } } } } if(window.location.href.indexOf('opencontribs=true') != -1) { window.location.href = (wo); } if(window.location.href.indexOf('opencontribs=true') == -1) { window.location.href = (go); } } }); }

//URL parameter function: //Originally from User:Lupin/autoedit.js function gvo(paramName) { var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)'); var h=document.location; var m; if (m=cmdRe.exec(h)) { try { return unescape(decodeURI(m[1])); } catch (someError) {} } return null; };

if(window.location.href.indexOf('action=delete') != -1 && document.title.indexOf('Action complete') == 0&&!deletetalk) { $(function { if(document.getElementById('t-whatlinkshere').firstChild.href.indexOf('&') != -1) { var chara = '&'; } else { var chara = '?'; } window.location.href = (document.getElementById('t-whatlinkshere').firstChild.href+chara+'delfrom=true'); }); } if(window.location.href.indexOf('delfrom=true') != -1&&!deletetalk) { $(function { var bx = document.getElementById('contentSub'); var hea = bx; var bxlw = document.createElement('div'); bxlw.id = "msgwrapper"; bxlw.innerHTML = ' Page successfully deleted!  '; hea.parentNode.insertBefore(bxlw, hea.nextSibling); }); }

//END //