User:GeorgeMoney/csd-base.js

// //_-_-_-_-_-_-_-_-_-_CSD-_-_-_-_ //Easy Speedy Delete script //Written by User:GeorgeMoney

if(window.location.href.indexOf('speedydel') != -1 && window.location.href.indexOf('action=delete') != -1) { addOnloadHook(function { doeasycsd; }); }

//Settings:

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

//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 = "A7";

//To open the creator's talk page and contribs 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 which is used when you have not predefined a special summary for one of the WP:CSD criterias var thedefaultsum = "Per Criteria for Speedy Deletion, $1";

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. extra1: "Extra summary",

//All the criterias. Replace defualtsum('foo') with "yoursummary". so   G1: defaultsum('G1'),  becomes   G1: "yoursummary", G1: defaultsum('G1'), G2: defaultsum('G2'), G3: defaultsum('G3'), G4: defaultsum('G4'), G5: defaultsum('G5'), G6: defaultsum('G6'), G7: defaultsum('G7'), G8: defaultsum('G8'), G9: defaultsum('G9'), G10: defaultsum('G10'), G11: defaultsum('G11'),

A1: defaultsum('A1'), A2: defaultsum('A2'), A3: defaultsum('A3'), A4: defaultsum('A4'), A5: defaultsum('A5'), A6: defaultsum('A6'), A7: defaultsum('A7'), A8: defaultsum('A8'),

R1: defaultsum('R1'), R2: defaultsum('R2'), R3: defaultsum('R3'),

I1: defaultsum('I1'), I2: defaultsum('I2'), I3: defaultsum('I3'), I4: defaultsum('I4'), I5: defaultsum('I5'), I6: defaultsum('I6'), I7: defaultsum('I7'), I8: defaultsum('I8'), I9: defaultsum('I9'),

C1: defaultsum('C1'), C2: defaultsum('C2'), C3: defaultsum('C3'),

U1: defaultsum('U1'), U2: defaultsum('U2'),

T1: defaultsum('T1'),

P1: defaultsum('P1'), P2: defaultsum('P2'),

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

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

var nocontent = nocontent.split('|'); //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 r = prompt('What speedy criteria?'); if(r == null) { alert('Action canceled'); return; } else if(r=="s") { var re = prompt('What extra summary?'); 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"?'); var usesum = re; var lr = "specnc"; var alm = false; } } 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; } window.location.href = (document.getElementById('ca-delete').firstChild.href+'&speedydel=true&delcrit='+escape(lr)+'&useurl=true'); 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'); 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 (i=0; i<inputs.length; i++) { if (inputs[i].name == 'wpConfirmB') { inputs[i].click; }       }        }

}

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; };

//-_-_-_-_-_-_-_-_-_-_END-_-_-_-_- //