User:Ozuzanna/annihilate.js

/*
 * "Annihilate" - a modified combined version of "WHAM!" and "Nuke + Block"
 * "WHAM!" - http://dev.wikia.com/wiki/WHAM/code.js
 * "Nuke + Block" - http://community.wikia.com/wiki/User:Lil'_Miss_Rarity/wikia.js
 * @author Ozuzanna

var nuke = -1, username = mw.config.get("wgPageName").split("/")[1], duration = "infinite";
 * (function($, mw) {

if (mw.config.get("wgCanonicalSpecialPageName") === "Contributions") { $(".chat-ban-log").after(' | Annihilate | Delete + Rollback | Nuke');

function deleteRollback { $('.mw-rollback-link a').each(function {	 var href = $(this).attr('href');	 $.get(href);	 $(this).text('gone!').css('color','grey').removeAttr('href');     }); var title = encodeURIComponent($('li .newpage ~ a').html), url = wgServer+'/api.php?action=query&prop=info&intoken=delete&titles='+title+'&format=json', deleteReason = 'spam'; $.getJSON(url, function(data) {	var p; for (p in data.query.pages) { break; }	var ET = data.query.pages[p].deletetoken;	ET = ET.slice(0, -2);       ET += '%2B\\';	$('li .newpage ~ a').each(function { var title = encodeURIComponent($(this).html), href = $(this).attr('href'); if (href.slice(0,7) === 'Thread:') nuke = 1; url = wgServer+'/api.php?action=delete&title='+title+'&reason='+deleteReason+'&format=json&token='+ET; $.post(url,function {		  $('li .newpage ~ a').css({'color':'grey','text-decoration':'line-through'}).removeAttr('href');	   }); });      });    }

$("#contribs-rollback-del").click(function {     deleteRollback;    });

$("#contribs-annihilate").click(function {     if (mw.config.get("wgTitle").split('.').length == 4) //anon        duration = "3 months";

$.ajax({           url: "/api.php",            type: "POST",            dataType: "JSON",            data: {                action: "block",                user: username,                expiry: duration,                reason: "spam",                nocreate: 0,                autoblock: 0,                format: "json",                token: mw.user.tokens.values.editToken            },            success: function (d) {                if (!d.error) {                    deleteRollback;                    if (nuke !== -1) {                      setTimeout((function{                      window.location.replace("/wiki/Special:Nuke/" + name);                      }), 3000);                     }                    else {                      setTimeout((function{                      location.reload;                      }), 3000);                     } } else { alert("Request failed: " + d.error.code); }           },            error: function  { alert("Request failed!"); }       });     });  } }) (this.jQuery, this.mediaWiki);