//<nowiki>
if (mw.config.get("wgNamespaceNumber") >= 0 && mw.config.get("wgIsProbablyEditable")) {
var oneClickDelete = {};
$(document).ready(function() {
oneClickDelete.addReason = function(reason, tag) {
oneClickDelete.reasons.push([tag, reason]);
//oneClickDelete.tag[reason] = tag;
};
oneClickDelete.delete = function(reason, tag) {
console.log("Getting token...");
$.get(mw.config.get("wgScriptPath") + "/api.php", {
"action": "query",
"meta": "tokens",
"type": "csrf",
"format": "json"
}).done(function(token) {
if (token.error) {
mw.notify($("<span class=\"error\">" + token.error.info + "</span>"));
} else {
var temp = tag.substring(3, 6);
if (temp.toLowerCase() != "st:" && temp.toLowerCase() != "c1") {
$.post(mw.config.get("wgScriptPath") + '/api.php', {
"action": "delete",
"format": "json",
"title": mw.config.get("wgPageName"),
"reason": reason + " ([[User:Awesome Aasim/oneclickdelete|One Click Deletion Script]])",
"token": token.query.tokens.csrftoken
}).done(function(editresult) {
if (editresult.error) {
mw.notify($("<span class=\"error\">" + editresult.error.info + "</span>"));
} else {
location.href = "/wiki/" + mw.config.get("wgPageName");
}
}).fail(function(editresult) {
mw.notify("<span class=\"error\">" + editresult + "</span>");
});
} else {
oneClickDelete.addTag(tag);
}
}
}).fail(function(token) {
mw.notify($("<span class=\"error\">" + token + "</span>"));
});
};
oneClickDelete.addTag = function(reason) {
if (reason) {
console.log("Getting wikitext...");
$.get(mw.config.get("wgScriptPath") + "/api.php", {
"action": "parse",
"prop": "wikitext",
"page": mw.config.get("wgPageName"),
"format": "json"
}).done(function(result) {
if (result.error) {
mw.notify($("<span class=\"error\">" + result.error.info + "</span>"));
} else if (result.parse.wikitext["*"].toLowerCase().substring(0, 100).includes("{{db") || result.parse.wikitext["*"].toLowerCase().substring(0, 100).includes("{{db")) {
mw.notify($("<span class=\"error\">" + "Page already tagged for speedy deletion. Please manually edit the tag instead of using this script." + "</span>"));
} else {
console.log("Getting token...");
$.get(mw.config.get("wgScriptPath") + "/api.php", {
"action": "query",
"meta": "tokens",
"type": "csrf",
"format": "json"
}).done(function(token) {
if (token.error) {
mw.notify($("<span class=\"error\">" + token.error.info + "</span>"));
} else {
console.log("Building wikitext and saving...");
var newwikitext = result.parse.wikitext["*"];
if (reason == "db-g10") {
newwikitext = "<noinclude>{{" + reason + "}}</noinclude>";
} else {
if (reason != "subst:void") {
newwikitext = "<noinclude>{{" + reason + "}}</noinclude>" + newwikitext;
} else {
newwikitext = "{{" + reason + "}}" + newwikitext;
}
}
$.post(mw.config.get("wgScriptPath") + '/api.php', {
"action": "edit",
"format": "json",
"title": mw.config.get("wgPageName"),
"text": newwikitext,
"summary": "Adding {{" + reason + "}} ([[User:Awesome Aasim/oneclickdelete|One Click Deletion Script]])",
"token": token.query.tokens.csrftoken
}).done(function(editresult) {
if (editresult.error) {
mw.notify($("<span class=\"error\">" + editresult.error.info + "</span>"));
} else {
location.href = "/wiki/" + mw.config.get("wgPageName");
}
}).fail(function(editresult) {
mw.notify("<span class=\"error\">" + editresult + "</span>");
});
}
}).fail(function(token) {
mw.notify($("<span class=\"error\">" + token + "</span>"));
});
}
}).fail(function(result) {
mw.notify($("<span class=\"error\">" + result + "</span>"));
});
}
};
oneClickDelete.select = $('<select name="deletiontemplate" style="width:100px" id="qcsd-dropdown" class="mw-ui-input"/>');
oneClickDelete.el = $('<div class="mw-indicator"><form id="qcsd"></form></div>');
$.get(mw.config.get("wgScriptPath") + "/api.php", {
"action": "parse",
"prop": "wikitext",
"format": "json",
"page": mw.config.get("wgPageName")
}).done(function(result) {
if (!result.error) {
// reasons begin
oneClickDelete.reasons = [];
// general
oneClickDelete.addReason("General", "-");
oneClickDelete.addReason("[[WP:G1|G1]]: Patent nonsense", "db-g1");
if (mw.config.get("wgNamespaceNumber") != 2) {
oneClickDelete.addReason("[[WP:G2|G2]]: Test page", "db-g2");
}
oneClickDelete.addReason("[[WP:G3|G3]]: Pure vandalism", "db-g3");
oneClickDelete.addReason("[[WP:G3|G3]]: Blatant hoax", "db-hoax");
oneClickDelete.addReason("[[WP:G4|G4]]: Recreation of a page deleted per a deletion discussion", "db-g4");
oneClickDelete.addReason("[[WP:G5|G5]]: Block/ban evasion", "db-g5");
oneClickDelete.addReason("[[WP:G6|G6]]: Page created in error", "db-error");
oneClickDelete.addReason("[[WP:G7|G7]]: Author request", "db-g7");
oneClickDelete.addReason("[[WP:G8|G8]]: Dependent on non-existent page", "db-g8");
if (result.parse.wikitext["*"].toLowerCase().substring(0, "#redirect".length).match(/.*\#redirect.*/g)) {
oneClickDelete.addReason("[[WP:G8|G8]]: Broken redirect", "db-redirnone");
} else {
if (mw.config.get("wgNamespaceNumber") % 2 == 1) {
oneClickDelete.addReason("[[WP:G8|G8]]: Talk page of non-existent page", "db-talk");
}
if (mw.config.get("wgPageName").includes("/") && mw.config.get("wgNamespaceNumber") != 0) {
oneClickDelete.addReason("[[WP:G8|G8]]: Subpage of non-existent page", "db-subpage");
}
if (mw.config.get("wgNamespaceNumber") == 6) {
oneClickDelete.addReason("[[WP:G8|G8]]: File description page with no corresponding file", "db-imagepage");
}
if (mw.config.get("wgNamespaceNumber") == 14) {
oneClickDelete.addReason("[[WP:G8|G8]]: Category populated by deleted/retargeted template", "db-templatecat");
}
}
oneClickDelete.addReason("[[WP:G10|G10]]: Attack page", "db-g10");
oneClickDelete.addReason("[[WP:G11|G11]]: Spam/unambiguous advertising", "db-g11");
if (mw.config.get("wgNamespaceNumber") == 2) {
oneClickDelete.addReason("[[WP:G11|G11]]: Spam user page", "db-spamuser");
}
oneClickDelete.addReason("[[WP:G13|G13]]: Abandoned drafts/AfC submissions", "db-g13");
oneClickDelete.addReason("[[WP:G14|G14]]: Unnecessary disambiguation", "db-g14");
if (result.parse.wikitext["*"].toLowerCase().substring(0, "#redirect".length).match(/.*\#redirect.*/g)) {
// redirect
oneClickDelete.addReason("Redirects", "-");
oneClickDelete.addReason('[[WP:R2|R2]]: Inappropriate cross-namespace redirect', 'db-r2');
oneClickDelete.addReason('[[WP:R3|R3]]: Implausible typo', 'db-r3');
if (mw.config.get("wgNamespaceNumber") == 6) {
oneClickDelete.addReason('Redirect with Wikimedia Commons match', 'db-r4');
}
} else {
if (mw.config.get("wgNamespaceNumber") == 0) {
// article
oneClickDelete.addReason("Articles", "-");
oneClickDelete.addReason('[[WP:A1|A1]]: No context', 'db-a1');
oneClickDelete.addReason('[[WP:A3|A3]]: No content', 'db-a3');
oneClickDelete.addReason('[[WP:A5|A5]]: Transwikied', 'db-a5');
//oneClickDelete.addReason('[[WP:A7|A7]]: No indication of importance (people, animals, organizations, web content, events)', 'db-a7');
oneClickDelete.addReason('[[WP:A7|A7]]: No indication of importance (person)', 'db-person');
oneClickDelete.addReason('[[WP:A7|A7]]: No indication of importance (band)', 'db-band');
oneClickDelete.addReason('[[WP:A7|A7]]: No indication of importance (club)', 'db-club');
oneClickDelete.addReason('[[WP:A7|A7]]: No indication of importance (organization)', 'db-inc');
oneClickDelete.addReason('[[WP:A7|A7]]: No indication of importance (web content)', 'db-web');
oneClickDelete.addReason('[[WP:A7|A7]]: No indication of importance (animal)', 'db-animal');
oneClickDelete.addReason('[[WP:A7|A7]]: No indication of importance (event)', 'db-event');
oneClickDelete.addReason('[[WP:A9|A9]]: No indication of importance (music recordings)', 'db-a9');
oneClickDelete.addReason('[[WP:A11|A11]]: Obviously invented', 'db-a11');
oneClickDelete.addReason('Unsourced biography', 'subst:prod blp');
}
if (mw.config.get("wgNamespaceNumber") == 6) {
// files
oneClickDelete.addReason("Files", "-");
oneClickDelete.addReason('[[WP:F2|F2]]: Corrupt file', 'db-f2');
oneClickDelete.addReason('[[WP:F3|F3]]: Improper license', 'db-f3');
oneClickDelete.addReason('No source', 'subst:nsd');
oneClickDelete.addReason('No license', 'subst:nld');
oneClickDelete.addReason('No source or license', 'subst:nsdnld');
oneClickDelete.addReason('[[WP:F5|F5]]: Non-free image used in now-deleted article', 'db-f5');
oneClickDelete.addReason('Orphaned non-free file', 'subst:orfud');
oneClickDelete.addReason('Orphaned non-free revisions', 'subst:orfurrev');
oneClickDelete.addReason('Missing non-free use rationale', 'subst:nrd');
oneClickDelete.addReason('[[WP:F7|F7]]: Obviously invalid fair use claim', 'db-f7');
oneClickDelete.addReason('Replacable with free images', 'subst:rfu');
oneClickDelete.addReason('Disputed fair use rationale', 'subst:dfu');
oneClickDelete.addReason('[[WP:F8|F8]]: File available on Commons', 'db-f8');
oneClickDelete.addReason('[[WP:F10|F10]]: Useless non-media file', 'db-f10');
oneClickDelete.addReason('No evidence of permission', 'subst:npd');
}
if (mw.config.get("wgNamespaceNumber") == 14) {
// categories
oneClickDelete.addReason("Categories", "-");
oneClickDelete.addReason('[[WP:C1|C1]]: Empty category', 'db-c1');
}
if (mw.config.get("wgNamespaceNumber") == 2 || mw.config.get("wgNamespaceNumber") == 3) {
// user pages
oneClickDelete.addReason("User pages", "-");
oneClickDelete.addReason('[[WP:U1|U1]]: User request', 'db-u1');
oneClickDelete.addReason('[[WP:U2|U2]]: Nonexistent user', 'db-u2');
oneClickDelete.addReason('[[WP:U3|U3]]: Non-free gallery', 'db-u3');
oneClickDelete.addReason('[[WP:U5|U5]]: Misuse of Wikipedia as a web host', 'db-u5');
}
if (mw.config.get("wgNamespaceNumber") == 100) {
// portals
oneClickDelete.addReason("Portals", "-");
oneClickDelete.addReason('[[WP:P1|P1]]: Meets article criteria for speedy deletion [[WP:A1|A1]]', 'db-p1|a1');
oneClickDelete.addReason('[[WP:P1|P1]]: Meets article criteria for speedy deletion [[WP:A3|A3]]', 'db-p1|a3');
oneClickDelete.addReason('[[WP:P1|P1]]: Meets article criteria for speedy deletion [[WP:A5|A5]]', 'db-p1|a5');
oneClickDelete.addReason('[[WP:P1|P1]]: Meets article criteria for speedy deletion [[WP:A7|A7]]', 'db-p1|a7');
oneClickDelete.addReason('[[WP:P1|P1]]: Meets article criteria for speedy deletion [[WP:A9|A9]]', 'db-p1|a9');
oneClickDelete.addReason('[[WP:P1|P1]]: Meets article criteria for speedy deletion [[WP:A11|A11]]', 'db-p1|a11');
oneClickDelete.addReason('[[WP:P2|P2]]: Underpopulated portal', 'db-p2');
}
}
oneClickDelete.select.append($('<option />').prop('disabled', true).prop('selected', true).text("OCD..."));
oneClickDelete.select.append($('<option />').attr('value', 'subst:void').text("Cancel"));
oneClickDelete.select.change(function(e) {
//debugger;
oneClickDelete.select.prop("disabled", true);
if (mw.config.get("wgUserGroups").includes("sysop")) {
oneClickDelete.delete($("#qcsd-dropdown option:selected").text(), $("#qcsd-dropdown").val());
} else {
oneClickDelete.addTag($("#qcsd-dropdown").val());
}
});
oneClickDelete.reasons.forEach(function(r) {
if (r[0] == "-") {
oneClickDelete.select.append($('<option />').prop('disabled', true).text(r[1]));
} else {
oneClickDelete.select.append($('<option />').attr('value', r[0]).text("\xA0\xA0" + r[1]));
}
});
oneClickDelete.el.appendTo("#siteNotice");
if (mw.config.get("skin") != "minerva") {
oneClickDelete.el.css({"float": "right", "margin-left": "10px"});
}
oneClickDelete.select.appendTo("#qcsd");
}
}).fail(function(result) {
});
});
}
//</nowiki>