Jump to content

User:R3m0t/delaid.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// 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 [[User talk:R3m0t/delaid.js|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 = '<table width="100%" cellpadding="10" style="font-size: 130%; text-align: center;"><tr><td style="background-color: #9CC" width="20%" onMouseDown="DelAidDo(\'G1\',event)">G1 Patent nonsense</td><td style="background-color: #9CC" width="20%" onMouseDown="DelAidDo(\'G3\',event)">G3 Vandalism</td><td style="background-color: #9CC" width="20%" onMouseDown="DelAidDo(\'G4\',event)">G4 Previously deleted</td><td style="background-color: #9CC" width="20%" onMouseDown="DelAidDo(\'G7\',event)">G7 Author\'s request</td><td style="background-color: #9CC" width="20%" onMouseDown="DelAidDo(\'G8\',event)">G8 Talk pages</td></tr><tr><td style="background-color: #9C9" onMouseDown="DelAidDo(\'A1\',event)">A1 No context</td><td style="background-color: #9C9" onMouseDown="DelAidDo(\'A3\',event)">A3 No content</td><td style="background-color: #9C9" onMouseDown="DelAidDo(\'A7\',event)">A7 Unremarkable people</td><td style="background-color: #F99" onMouseDown="DelAidDo(\'I1\',event)">I1 Redundant</td><td style="background-color: #F99" onMouseDown="DelAidDo(\'I5\',event)">I5 Copyrighted</td></tr><tr><td> </td></tr><tr><td style="background-color: #9C9" onMouseDown="DelAidDo(\'A2\',event)">A2 Foreign language (copied)</td><td style="background-color: #9C9" onMouseDown="DelAidDo(\'A5\',event)">A5 Transwikied</td><td style="background-color: #F99" onMouseDown="DelAidDo(\'I2\',event)">I2 Corrupt</td><td style="background-color: #9CC" onMouseDown="DelAidDo(\'G2\',event)">G2 Test pages</td><td style="background-color: #9CC" onMouseDown="DelAidDo(\'G5\',event)">G5 Banned user</td></tr><tr><td style="background-color: #9CC" onMouseDown="DelAidDo(\'G10\',event)">G10 Attack pages</td><td style="background-color: #F99" onMouseDown="DelAidDo(\'I3\',event)">I3 Bad license</td><td style="background-color: #F99" onMouseDown="DelAidDo(\'I4\',event)">I4 No license</td><td style="background-color: #9CC" onMouseDown="DelAidDo(\'G6\',event)">G6 House keeping</td><td style="background-color: #9CC" onMouseDown="DelAidDo(\'G11\',event)">G11 Advertising</td></tr><tr><td> </td></tr><tr><td style="background-color: #9FF" onMouseDown="DelAidDo(\'R1\',event)">R1 Broken redirect</td><td style="background-color: #9FF" onMouseDown="DelAidDo(\'R2\',event)">R2 To userspace</td><td style="background-color: #9FF" onMouseDown="DelAidDo(\'R3\',event)">R3 Unlikely typo</td><td style="background-color: #C9C" onMouseDown="DelAidDo(\'U1\',event)">U1 Owner\'s request</td><td style="background-color: #C9C" onMouseDown="DelAidDo(\'U2\',event)">U2 No such user</td></tr><tr><td> </td></tr><tr><td style="background-color: #FF6" onMouseDown="DelAidDo(\'C1\',event)">C1 Empty category</td><td style="background-color: #FF6" onMouseDown="DelAidDo(\'C2\',event)">C2 Renamed</td><td style="background-color: #FF6" onMouseDown="DelAidDo(\'C3\',event)">C3 Templated</td><td style="background-color: #9CC" onMouseDown="DelAidDo(\'G12\',event)">G12 Copyvio</td><td onMouseDown="DelAidDo(\'-\',event)">Visit Home</td></tr><tr><td> </td></tr><tr><td style="background-color: #F93" onMouseDown="DelAidDo(\'T1\',event)">T1 Inflammatory</td><td style="background-color: #CCC" onMouseDown="DelAidDo(\'WP:PROD\',event)">WP:PROD</td><td>&nbsp;</td><td style="background-color: #CCC" onMouseDown="DelAidDo(\'\',event)">Enter reason</td></tr></table>';
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);