User:Lor-break/global.js

/*  var ug = mw.config.get("wgUserGroups"); if (mw.config.get("wgCanonicalSpecialPageName") === "Contributions" && (ug.indexOf('rollback') + ug.indexOf('sysop') + ug.indexOf('vstf') + ug.indexOf('staff') + ug.indexOf('helper') > -5)) { /*    var walls = [ "Message Wall", "Nachrichtenseite", "Muro", "Viestiseinä", "Mur", "Üzenőfal", "Bacheca", "メッセージ ウォール", "Prikbord", "Tablica wiadomości", "Mural de mensagens", "Стіна обговорення", "Стена обсуждения", "留言墙" ],   username = mw.config.get("wgPageName").split("/")[1], token = mw.user.tokens.get("editToken"), revDel = 0; if ($('.mw-revdelundel-link').length) revDel = 1; $("#contentSub").append(' Quick Tools'); $('#contribs-wham').click(function {     $.showCustomModal('WHAM!', '', { id: 'form-main', width: 660, buttons: [{ message: 'Delete all pages', defaultButton: true, handler: function { doDelete; }	       },{		           message: 'Delete selected', defaultButton: true, handler: function { startSelectiveDelete; }       },{		           message: 'Rollback all edits', defaultButton: true, handler: function { doRollback; }       },{		           message: 'Quick block', defaultButton: true, handler: function { doBlock; }       },{		           message: 'All of the options', defaultButton: true, handler: function { doRollback; doDelete; doBlock; closeRefresh; }       },{          message: 'Cancel', handler: function { closeRefresh; }       }]      });      $(".close").click(closeRefresh);      mw.util.addCSS('.modalWrapper .modalContent .modalToolbar {text-align:left;}');    }); function apiDelete(page,reason) { new mw.Api.post({     format: 'json',      action: 'delete',      title: page,      reason: reason,      bot: true,      token: token      }) .done(function(d) {        if (!d.error) {          console.log('Deletion of '+page+' successful!');        } else {          console.log('Failed to delete '+page+': '+ d.error.code);        }      }) .fail(function {       console.log('Failed to delete '+page+'!');      }); }   function closeRefresh { $('#form-main').closeModal; setTimeout((function{ location.reload; }), 5000);   }    function doRollback { $('.mw-rollback-link a').each(function {       var href = $(this).attr('href');	$.get(href);        $(this).text('gone!').css({'color':'grey','text-decoration':'line-through'}).removeAttr('href').parents.eq(1).css({'color':'grey','text-decoration':'line-through'}).children.removeAttr('href').css({'color':'grey','text-decoration':'line-through'});      }); }   function doDelete { var deleteReason = prompt('Please enter the delete reason','cleanup'); if (!deleteReason) return; $('li .newpage ~ a').each(function {       var title = $(this).attr('title');        if (walls.indexOf(title.split(':')[0]) !== -1)          return;        apiDelete(title,deleteReason);        $(this).parent.css({'color':'grey','text-decoration':'line-through'}).children.removeAttr('href').css({'color':'grey','text-decoration':'line-through'});      }); $('#mw-content-text ul li').each(function {       var title = $(this).children('a').first.attr('title');	if (title.split('-').length == 1 || title.split('/@comment').length == 1)	  return;           apiDelete(title,deleteReason);        $(this).css({'color':'grey','text-decoration':'line-through'});      }); }   function doBlock { var duration = prompt('Please state the block duration','2 weeks'), blockReason = prompt('Please state the block reason','Vandalism'); if (!duration || !blockReason) return; new mw.Api.post({     format: 'json',      action: 'block',      user: username,      expiry: duration,      nocreate: 0,      autoblock: 0,      reason: blockReason,      bot: true,      token: token      }) .done(function(d) {        if (!d.error) {          console.log(username+' has been blocked successfully!');        }         else {          alert('Failed to block '+username+': '+ d.error.code);        }      }) .fail(function {       alert('Failed to block '+username+'!');      }); }   function startSelectiveDelete { var chk = ' '; $('#form-main').closeModal; if ($('#btn-wham-del').length && $('#btn-wham-check').length) return; $('#mw-content-text').find('ul').before('Delete Selected Check All'); $('li .newpage ~ a').each(function {       if (!$(this).parent.find('input').length)          $(this).parent.prepend(chk);      }); $('#mw-content-text ul li').each(function {       var title = $(this).children('a').first.attr('title');	if (title.split('-').length != 1 && title.split('/@comment').length != 1 && !$(this).find('input').length && title.split(username) != -1)          $(this).prepend(chk);	      }); $('#btn-wham-del').click(function {       var deleteReason = prompt('Please enter the delete reason','cleanup');        if (!deleteReason)          return;        $('.selectiveDel').each(function { var chkObj = $(this); if (revDel == 0) { var title = $(this).parent.find('a').first.attr('title'); }         else { var title = $(this).parent.children('a').eq(1).attr('title'); }         if (chkObj.attr('Checked') && walls.indexOf(title.split(':')[0]) == -1) { apiDelete(title,deleteReason); $(this).parent.css({'color':'grey','text-decoration':'line-through'}).children.removeAttr('href').css({'color':'grey','text-decoration':'line-through'}); }       });        setTimeout((function{          location.reload;        }), 5000);      }); $('#btn-wham-check').click(function {       var btn = $(this);        if (btn.text == 'Uncheck All') {          $('.selectiveDel').each(function { var chkObj = $(this); if (chkObj.attr('checked')) chkObj.removeAttr('checked'); });         btn.text('Check All');        }        else {          $('.selectiveDel').each(function { var chkObj = $(this); if (!chkObj.attr('checked')) chkObj.attr('checked','checked'); });         btn.text('Uncheck All');         }      }); } } }) (this.jQuery, this.mediaWiki); //
 * A modified version of WHAM with a more up-to-date modal, as well as less coding
 * Includes functionality to delete forum/message wall threads and selective deleting of pages, which the original doesn't have
 * Original "WHAM" - http://dev.wikia.com/wiki/WHAM/code.js
 * @author Ozuzanna
 * @TODO interlang message translations
 * (function($, mw) {
 * Message wall equivalents list, used to prevent deletion of message walls (causes glitches and not necessary)
 * Acquired from https://github.com/Wikia/app/blob/ae6cd75a04ba92270931d8fee70f14d40146091b/extensions/wikia/Wall/Wall.namespaces.php