User:R3m0t/delaid.js

// for instructions, see User talk:R3m0t/delaid.js

if (typeof alwaysReason == 'undefined') { alwaysReason = false; }

if (typeof altAction == 'undefined') { altAction = 'reason'; }

if (typeof defaultReturn == 'undefined') { defaultReturn = "http://en.wikipedia.org/w/index.php?title=Category:Candidates_for_speedy_deletion&action=purge"; }

/**

  • Sets a Cookie with the given name and value.
  • name Name of the cookie
  • value Value of the cookie
  • [expires] Expiration date of the cookie (default: end of current session)
  • /

function DAsetCookie(name, value, expires, path) {

document.cookie= "da_" + name + "=" + escape(value) +

((expires) ? "; expires=" + expires.toGMTString() : "") +

"; path=/";

}

/**

  • Gets the value of the specified cookie.
  • name Name of the desired cookie.
  • Returns a string containing value of specified cookie,
  • or null if cookie does not exist.
  • /

function DAgetCookie(name) {

var dc = document.cookie;

var prefix = "da_" + name + "=";

var begin = dc.indexOf("; " + prefix);

if (begin == -1) {

begin = dc.indexOf(prefix);

if (begin != 0) return null;

} else {

begin += 2;

}

var end = document.cookie.indexOf(";", begin);

if (end == -1) {

end = dc.length;

}

return unescape(dc.substring(begin + prefix.length, end));

}

function DelAidLink() {

if ((DAgetCookie('delaid') != '') && (DAgetCookie('delaid') != '-') && ((DAgetCookie('delaid') + '!') != 'null!') && (document.title == "Confirm deletion - Wikipedia, the free encyclopedia")) {

if (document.getElementById("wpReason").value == '') {

document.getElementById("wpReason").value = DAgetCookie('delaid') + ' || Deletion aided with delaid';

} else {

document.getElementById("wpReason").value = DAgetCookie('delaid') + ' || ' + document.getElementById("wpReason").value;

}

DAsetCookie('delaid', '-');

document.forms[0].wpConfirmB.click();

} else if ((DAgetCookie('delaid') == '-') && (document.title == "Action complete - Wikipedia, the free encyclopedia")) {

DAsetCookie('delaid', '');

go = DAgetCookie('returnpage');

if (go == null) { go = defaultReturn; }

document.location.href = go;

} else {

var link = document.createElement('a');

link.href = 'javascript:DelAid()';

link.title = 'Speedy puff!';

link.accessKey = '`';

link.appendChild(document.createTextNode('Speedy'));

var li = document.createElement('li');

li.appendChild(link);

document.getElementById("p-tb").getElementsByTagName('ul')[0].appendChild(li);

}

}

function DelAid() {

insertion = document.getElementById("contentSub");

objt = document.createElement("div");

objt.innerHTML = '

G1 Patent nonsenseG3 VandalismG4 Previously deletedG7 Author\'s requestG8 Talk pages
A1 No contextA3 No contentA7 Unremarkable peopleI1 RedundantI5 Copyrighted
A2 Foreign language (copied)A5 TranswikiedI2 CorruptG2 Test pagesG5 Banned user
G10 Attack pagesI3 Bad licenseI4 No licenseG6 House keepingG11 Advertising
R1 Broken redirectR2 To userspaceR3 Unlikely typoU1 Owner\'s requestU2 No such user
C1 Empty categoryC2 RenamedC3 TemplatedG12 CopyvioVisit Home
T1 InflammatoryWP:PROD Enter reason
';

insertion.parentNode.insertBefore(objt, insertion);

}

function DelAidDo(msg, ev) {

hasAlt = ev.altKey;

if (msg == '-') {

if (hasAlt) {

DAsetCookie('returnpage', document.location.href);

alert("Delaid home set to " + document.location.href);

} else {

go = DAgetCookie('returnpage');

if (go == null) { go = defaultReturn; }

document.location.href = go;

}

return;

}

if ((alwaysReason || (hasAlt && (altAction == "reason")) || (msg == '')) && !(hasAlt && (altAction == "noreason"))) {

addition = prompt('Reason','');

if (!addition) { return; }

if (addition != '') {

msg = msg + ' (' + addition + ')';

}

}

DAsetCookie('delaid', msg);

if (!document.getElementById("ca-delete")) {

document.location.href = "http://en.wikipedia.org/w/index.php?action=delete&title=" + escape(document.getElementsByTagName('h1')[0].firstChild.nodeValue);

}

document.location.href = document.getElementById("ca-delete").firstChild.href;

}

if (window.addEventListener) window.addEventListener("load",DelAidLink,false);

else if (window.attachEvent) window.attachEvent("onload",DelAidLink);