MediaWiki:Discussions Delete All/code.js

// Discussions Delete All //  Button from Special:Contribs that deletes all Discussions posts of user // @author: Jr Mime

$(function { dda = {};  dda.init = function {    if ($("#discussionAllPostsByUser").length == 0) return;    if (!mw.config.get("wgUserGroups").join(",").match(/(threadmoderator|staff|sysop|vstf|helper|global-discussions-moderator)/)) return;    var wikiID = mw.config.get("wgCityId"),        userID = $("#user").attr("value"),        doNotConfirm = (typeof(ddaDoNotConfirm) === "undefined") ? false : ddaDoNotConfirm;    $(".tally span").css("float", "none");    $("#discussionAllPostsByUser").after(" delete-all ");    $("#dda").on("click", function { if (!doNotConfirm) { var ddaConfirm = confirm("Are you sure you want to delete all posts by this user?"); if (ddaConfirm == true) dda.deleteAll(wikiID, userID); } else { dda.deleteAll(wikiID, userID); }   });  }  dda.deleteAll = function(wiki, user) {    $.ajax({ url: 'https://services.wikia.com/discussion/' + wiki + '/users/' + user + '/posts/delete', type: 'PUT', xhrFields: { withCredentials: true },     crossdomain: true }).done(function(data) { $("span#dda").replaceWith("done!"); }); }  if (mw.config.get('wgCanonicalSpecialPageName') == 'Contributions') dda.init; });