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

/** function DAsetCookie(name, value, expires, path) { document.cookie= "da_" + name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString : "") + "; path=/"; }
 * 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)
 * [expires] Expiration date of the cookie (default: end of current session)

/** 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)); }
 * 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.
 * Returns a string containing value of specified cookie,
 * or null if cookie does not exist.

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 = ' '; 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);