MediaWiki:Gadget-massblock.js

Attention : Depuis MediaWiki 1.18 les pages se terminant avec l'extension .js ou .css sont interprétées comme des pages wiki ! En particulier les modèles (subst ou non) et les liens. Vous devez donc migrer le code source et effectuer vos changements en évitant ces éléments de syntaxe wiki (peu importe leurs emplacements dans le code source : commentaire, chaine) :

  • Double accolades ouvrantes (en particulier avec subst:) : séparer les deux accolades "{"+"{" du reste de la chaine
  • Double crochets ouvrants : même technique de séparation.
  • Signature (tildes ~ multiples) : même technique de séparation.

Note : après avoir enregistré vos préférences, vous devrez attendre que le serveur mette à jour la feuille de style globale avant de forcer le rechargement complet du cache de votre navigateur pour voir les changements.

  • Firefox / Safari : Maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou pressez Ctrl-F5 ou Ctrl-R (⌘-R sur un Mac) ;
  • Google Chrome : Appuyez sur Ctrl-Maj-R (⌘-Shift-R sur un Mac) ;
  • Internet Explorer : Maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5 ;
  • Konqueror : Cliquez sur Actualiser ou pressez F5 ;
  • Opera : Videz le cache dans Outils → Préférences.
wgfrwikibooks_Gadget_massblockJsVersion = "20150117001";
wgGadget_massblockJsVersion = "20120418004";
//[[Catégorie:MediaWiki:Fonction Monobook en JavaScript|massblock]]

// Voir aussi [[MediaWiki:Gadget-blockoptions.js]]
// After adding to your monobook.js, navigate to [[Special:Massblock]] to use the tool.
 
function getParameter(p) {
  var re = new RegExp('&'+p+'=([^&]*)','i');
  var c = window.location.search; 
  return unescape((c=c.replace(/^\?/,'&').match(re)) ?c=c[1] :c="");
}
 
function massblock() {
  if (mw.config.get('wgPageName') == "Spécial:Massblock"||mw.config.get('wgPageName') == "Spécial:Blocage en masse") { // Cette page bug actuellement
    document.title = "Mass block tool";
    setDOM(document.getElementById("content"),
      "Liste des IPs à bloquer, une par ligne VSP:\n",
      ["textarea", {"id":"iplist", "columns":"24", "rows":"10"}],
      "\n\nExpiration : ",
      ["input",{"type":"text","value":"2 years","id":"expiry"}],
      "\nRaison : ",
      ["input",{"type":"text","value":"Proxy ouvert ou ordinateur zombi","id":"reason"}],
      "\n",
      ["input",{"type":"checkbox","id":"ao"}],
      ["label",{"for":"ao"},"Anonymes seulement"],
      "\n",
      ["input",{"type":"checkbox","id":"acb", "checked":"checked"}],
      ["label",{"for":"acb"},"Empêcher la création de compte"],
      "\n\nBlocks/min : ",
      ["input",{"type":"text","value":"10","id":"epm"}],
      "\n",
      ["button",{"onclick":"massblock2()"},"Bloquer les IPs"],
      ["button",{"onclick":"massblock4()"},"Annuler"],
      ["div",{"style":{"z-index":-1,"position":"relative","top":"0px","left":"0px"}},
          ["iframe",{"name":"blockframe0","width":"1px","height":"1px"}],
          ["iframe",{"name":"blockframe1","width":"1px","height":"1px"}],
          ["iframe",{"name":"blockframe2","width":"1px","height":"1px"}],
          ["iframe",{"name":"blockframe3","width":"1px","height":"1px"}],
          ["iframe",{"name":"blockframe4","width":"1px","height":"1px"}],
          ["iframe",{"name":"blockframe5","width":"1px","height":"1px"}]
      ]);
  } else if (document.location.search.match("__MASSBLOCK__")) {
      document.getElementById("wpAnonOnly").checked = getParameter("ao") == "1";
      document.getElementById("wpCreateAccount").checked = getParameter("acb") == "1";
      document.getElementById("mw-bi-other").value = getParameter("expiry").replace("+"," ","g");
      document.getElementById("mw-bi-reason").value = getParameter("reason").replace("+"," ","g");
      setTimeout("document.getElementById(\"blockip\").submit()", 500);
  }
}
 
var wgBlocksToDo;
var wgBlocksToDoIndex;
var wgBlocksToDoInterval = 0;
var wgBlockFrame;
function massblock2() {
  if (!parseFloat(document.getElementById("epm").value)) return;
  wgBlocksToDo = new Array();
 
  iplist = document.getElementById("iplist").value.split("\n");
  for (i=0;i<iplist.length;i++) {
    wgBlocksToDo[i] = iplist[i].split(":")[0];
  }
 
  mbcode = "massblock3(wgBlocksToDo[wgBlocksToDoIndex++]);if (wgBlocksToDoIndex >= wgBlocksToDo.length) massblock4();";
 
  wgBlocksToDoIndex = wgBlockFrame = 0;
  eval(mbcode);
  wgBlocksToDoInterval = setInterval(mbcode, (60 / parseFloat(document.getElementById("epm").value)) * 1000);
}
 
function massblock3(ipToBlock) {
  if (ipToBlock + "" == "undefined") return;
 
  iplistobj = document.getElementById("iplist");
  if (iplistobj.value.indexOf("\n") == -1) iplistobj.value = "";
  iplistobj.value = iplistobj.value.substring(iplistobj.value.indexOf("\n") + 1);
 
  if (ipToBlock == "") return;
 
  frames["blockframe" + wgBlockFrame++].location.href = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=Special:Blockip&ip=" + ipToBlock + "&__MASSBLOCK__=1&expiry=" + document.getElementById("expiry").value + "&reason=" + document.getElementById("reason").value + "&ao=" + (document.getElementById("ao").checked ? "1" : "0") + "&acb=" + (document.getElementById("acb").checked ? "1" : "0");
  if (wgBlockFrame == 6) wgBlockFrame = 0;
}
 
function massblock4() {
  clearInterval(wgBlocksToDoInterval);
}
 
$(massblock);