Jump to content

MediaWiki:Group-sysop.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
updated code
updated code
Line 192: Line 192:
ips = Array(
ips = Array(
Array(/\b63\.162\.143\.21\b/, 'the [[United States Department of Homeland Security|U.S. Department of Homeland Security]]'),
Array(/\b63\.162\.143\.21\b/, 'the [[United States Department of Homeland Security|U.S. Department of Homeland Security]]'),
Array(/\b82\.148\.(96\.68|97\.69)\b/, '[[Qatar|Qatar]]'),
Array(/\b82\.148\.9(6\.68|7\.69)\b/, '[[Qatar|Qatar]]'),
Array(/\b128\.183\.103\.97\b/, '[[NASA|NASA]]'),
Array(/\b128\.183\.103\.97\b/, '[[NASA|NASA]]'),
Array(/\b130\.22\.[0-9]{1,3}\.[0-9]{1,3}\b/, 'the [[United States Department of Defense|U.S. Department of Defense]]'),
Array(/\b(((2|5)?6|7|[12]1|2(2|8|9)|3(0|3)|55)\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))|130\.22|)(\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}\b/, 'the [[United States Department of Defense|U.S. Department of Defense]]'),
Array(/\b138\.16(2|3)\.[0-9]{1,3}\.[0-9]{1,3}\b/, 'the [[United States Navy|U.S. Naval Telecommunications Station]]'),
Array(/\b138\.16[23](\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}\b/, 'the [[United States Navy|U.S. Naval Telecommunications Station]]'),
Array(/\b143\.2(28|29|30|31)\.[0-9]{1,3}\.[0-9]{1,3}\b/, 'the [[United States House of Representatives|U.S. House of Representatives]]'),
Array(/\b143\.2(2[89]|3[01])(\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}\b/, 'the [[United States House of Representatives|U.S. House of Representatives]]'),
Array(/\b149\.101\.[0-9]{1,3}\.[0-9]{1,3}\b/, 'the [[United States Department of Justice|U.S. Department of Justice]]'),
Array(/\b149\.101(\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}\b/, 'the [[United States Department of Justice|U.S. Department of Justice]]'),
Array(/\b156\.33\.[0-9]{1,3}\.[0-9]{1,3}\b/, 'the [[United States Senate|U.S. Senate]]'),
Array(/\b156\.33(\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}\b/, 'the [[United States Senate|U.S. Senate]]'),
Array(/\b162\.4(5|6)\.[0-9]{1,3}\.[0-9]{1,3}\b/, 'the [[Central Intelligence Agency|U.S. Central Intelligence Agency]]'),
Array(/\b(162\.4[56]\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))|198\.81\.(128|129|1[3-8]\d|191))\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))\b/, 'the [[Central Intelligence Agency|U.S. Central Intelligence Agency]]'),
Array(/\b192\.197\.(77|78|79|80|81|82|83|84|85|86)\.[0-9]{1,3}\b/, 'the [[Government of Canada|Government of Canada]]'),
Array(/\b192\.197\.(7[7-9]|8[0-6])\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))\b/, 'the [[Government of Canada|Government of Canada]]'),
Array(/\b\194.60.[0-9][0-5]?\.[0-9]{1,3}\b/, 'the [[Parliament of the United Kingdom|U.K. Parliament]]'),
Array(/\b(51(\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}|194.60.\d[0-5]?)\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))\b/, 'the [[Parliament of the United Kingdom|U.K. Parliament]]'),
Array(/\b198\.81\.(128|129|1[3-8][0-9]|191)\.[0-9]{1,3}\b/, 'the [[Central Intelligence Agency|U.S. Central Intelligence Agency]]'),
Array(/\b66\.230\.(19[2-9]|2[0-3]\d)\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))\b/, 'the [[Wikimedia Foundation|Wikimedia secure gateway]]'),
Array(/\b66\.230\.(192|193|194|195|196|197|198|199|2[0-3][0-9])\.[0-9]{1,3}\b/, 'the [[Wikimedia Foundation|Wikimedia secure gateway]]'),
Array(/\b91\.198\.174\.(19[2-9]|2([01]\d|2[0-3]))\b/, 'the [[m:Toolserver|Wikimedia Toolserver]]')
Array(/\b91\.198\.174\.(19[2-9]|2((0|1)[0-9]|2[0-3]))\b/, 'the [[m:Toolserver|Wikimedia Toolserver]]')
);
);
ip = document.getElementById('mw-bi-target').value;
ip = document.getElementById('mw-bi-target').value;
if (/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/.test(ip))
if (/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/.test(ip))
{
{
for (i=0; i < ips.length; i++)
for (i = 0; i < ips.length; i++)
{
{
if (ip.match(ips[i][0]))
if (ip.match(ips[i][0]))

Revision as of 05:06, 30 June 2008

 /** Creates a button to invert checkboxes on Special:Undelete */
 if (wgCanonicalNamespace == "Special" && wgCanonicalSpecialPageName == "Undelete") {
     (function () {
         var form             = document.forms["undelete"];
         if( !form ) {
             return;
         }
         var elements         = form.elements;
         var submitButton     = elements["mw-undelete-submit"];
         if( !submitButton ) {
             return;
         }
         var toggleButton     = document.createElement("input");
         toggleButton.type    = "button";
         toggleButton.value   = "Invert selection";
         
         toggleButton.onclick = function () {
                 for( var i = 0; i < elements.length; ++i ) {
                     var input = elements[i];
                     if( input.type != "checkbox" ) {
                         continue;
                     }
                     input.checked = !input.checked;
                 }
             };
         submitButton.parentNode.insertBefore( toggleButton, submitButton );
     })();
 }

 /** Clean CSD G10 deletion summaries ******************************************
  *
  *  Description: Replaces autogenerated deletion summaries for articles tagged
  *               for speedy deletion as attack pages (CSD G10) with a neutral
  *               summary that avoids including any part of the article content
  *               in the deletion log.
  *  Maintainers: [[User:Ilmari Karonen]]
  */
 if (wgAction == "delete") {
     (function () {
         var wpReason = document.getElementById("wpReason");
         if (!wpReason) return;
         var regexp = /\{\{\s*(msg:\s*)?(template:\s*)?(db-a(p|tk)?|((csd|db)[-:])?(a6|attack(pages?|template)?|g10))\s*[|}]/i;
         if (regexp.test(wpReason.value))
             wpReason.value = "[[WP:CSD#G10|CSD G10]]: [[Wikipedia:Attack page|Attack Page]]";
     })();
 }
 /*
  * Note: These are the known redirects to [[Template:Db-attack]] as of 7 Jun 2007.
  * The regexp above should catch these as well as a number of possible variants.
  *
  * [[Template:A6]]
  * [[Template:Attackpage]]
  * [[Template:Attackpages]]
  * [[Template:CSD:G10]]
  * [[Template:Csd-a6]]
  * [[Template:Db-Attack]]
  * [[Template:Db-a]]
  * [[Template:Db-a6]]
  * [[Template:Db-ap]]
  * [[Template:Db-atk]]
  * [[Template:Db-attack]]
  * [[Template:Db-attacktemplate]]
  * [[Template:Db-g10]]
  * [[Template:G10]]
  */

 /** Automatic deletion dropdown
  *******************************************************
  *
  *  Description: Augments the drop-down menu of standard deletion reasons
  *               generated from [[MediaWiki:Deletereason-dropdown]], to 
  *               automatically pick a reason from the list based on speedy 
  *               deletion tags.
  *  Maintainers: [[User:Random832]]
  */
 if (wgAction == 'delete' && typeof(csdDeleteForm) == 'undefined') {
  (function() { // scope
  var list = document.getElementById('wpDeleteReasonList');
  if(!list) return;
  var summaryBox = document.getElementById('wpReason') || document.getElementById('wpComment');
  if(!summaryBox) return;
  var re = /\[\[([^\]\|]*\|)?([^\]]*)\]\]/g; // convert pipe links to their display text.
  for(var i=0;i<list.options.length;i++) {
     var o=list.options[i];
     o.text = o.text.replace(re,'$2');
  }
  function csdChangeBox() {
   if(summaryBox.value.indexOf('content was:') != -1) summaryBox.value = '';
  }
  function addEvent(obj, evType, fn, useCapture){
       //alert(obj);
       if (obj.addEventListener) {
         obj.addEventListener(evType, fn, useCapture);
         return true;
       } else if (obj.attachEvent) {
         var r = obj.attachEvent("on"+evType, fn);
         return r;
       } else {
         alert("Handler could not be attached");
       }
  }
  function findCSD(s) { // s e.g. "U1", "G10"
    for(var i=0;i<list.options.length;i++) {
       var o=list.options[i];
       if (o.text.indexOf("CSD "+s+":") == 0) return o;
       if (o.text.indexOf(s+":") == 0) return o;
       //TODO fine-tuning for A7 and G6
    }
  }
  var reasons_regex = {
     'G10': // copied from [[User:Ilmari Karonen]]'s script, covers more bases than the others since it's more important (this script should blank the summary in _all_ cases where the other script does
/\{\{\s*(msg:\s*)?(template:\s*)?(db-a(p|tk)?|((csd|db)[-:])?(a6|attack(pages?|template)?|g10))\s*[|}]/i,
// other regexes are simpler and cover probably 99% of actual tags.
     'G1': /\{\{\s*(db-|csd[-:])?(nonsense|ns|g1)\s*\}\}/i,
     'G2': /\{\{\s*(db-|csd[-:])?(test|g2)\s*\}\}/i,
     'G3': /\{\{\s*(db-|csd[-:])?(vandalism|vandal|vand|g3)\s*\}\}/i,
     'G4': /\{\{\s*((db-|csd[-:])?(repost|g4)|deleteagain)\s*\}\}/i,
     'G5': /\{\{\s*(db-|csd[-:])?(banned|ban|g5)\s*\}\}/i,
     'G6': /\{\{\s*(db-|csd[-:])?(maintenance|move|histmerge|g6)\s*\}\}/i, // db-move and db-histmerge should be covered elsewhere if possible
     'G7': /\{\{\s*(db-|csd[-:])?(author|blanked|g7)\s*\}\}/i,
     'G8': /\{\{\s*(db-|csd[-:])?(talk|g8)\s*\}\}/i,
     // G9 is for office, there is no tag.
     // G10 is covered above
     'G11': /\{\{\s*(db-|csd[-:])?(spam|ad|advert|g11)\s*\}\}/i,
     'G12': /\{\{\s*(db-|csd[-:])?(copyvio|cv|cvio|g12|a8)\s*(\}\}|\|)/i,
     'A1': /\{\{\s*(db-|csd[-:])?((no)?context|a1)\s*\}\}/i,
     'A3': /\{\{\s*(db-|csd[-:])?((no)?content|a3|contact|a4)\s*\}\}/i,
     // A4 = A3
     // A6 = G10
     'A7 (bio)': /\{\{\s*(nn-|db-|csd[-:])?(a7|notability|bio|person)\s*\}\}/i,
     'A7 (web)': /\{\{\s*(nn-|db-|csd[-:])?(web(site)?|inter(net|tubes))\s*\}\}/i,
     'A7 (group)': /\{\{\s*(db-|csd[-:]|nn-)?(band|club|music|inc|corp|comp(any)?)\s*\}\}/i,
              // TODO separate for music/band?
      // A8 = G12
     'C1': /(\{\{\s*(db-|csd[-:])?(emptycat|c1)\s*\}\}|empty category)/i,
     'U1': /\{\{\s*(db-|csd[-:])?(userreq|u1|user)\s*\}\}/i,
     'I2': /\{\{\s*(db-|csd[-:])?(noimage|i2)\s*\}\}/i,
     'R1': /\{\{\s*(db-|csd[-:])?(redirnone|r1)\s*\}\}/i,
     // no point in including the other image categories here, this will only work
     // when deleting a description page with no image
     'dummy': /this will never be reached, it is there to allow every entry above to end in a comma/
  }
  function autopick_deletion_reason() {
   for(var csd in reasons_regex) {
     if(reasons_regex[csd].test(summaryBox.value)) {
        var option = findCSD(csd);
        if(!option) {
            if(csd == 'G10')
            summaryBox.value = "[[WP:CSD#G10|CSD G10]]: [[Wikipedia:Attack page|Attack Page]]"; // last resort, if G10 can't be found in the menu.
            return;
        }
        list.selectedIndex = option.index;
        csdChangeBox(); // clear summary box
     }
   }
   // TODO "content before blanking" and A7, etc.
   // TODO We can autodetect G8 from the namespace and a redlinked tab.
   var xfdregex = /.*\{\{AfDM\|page=([^\|]*)\|.*/;
   if(xfdregex.test(summaryBox.value))  { 
      summaryBox.value = summaryBox.value.replace(xfdregex,'[[Wikipedia:Articles for deletion/$1]]');
      return;
   }
   xfdregex = /.*\{\{mfdtag\|([^}]*)\}\}.*/;
   if(xfdregex.test(summaryBox.value))  { 
      summaryBox.value = summaryBox.value.replace(xfdregex,'[[Wikipedia:Miscellany for deletion/$1]]');
      return;
   }
   xfdregex = /.*\{\{dated prod\|concern = (\{\{\{concern\|)?(.*?)(\}\}\})?\|month.*/;
   if(xfdregex.test(summaryBox.value))  { 
      summaryBox.value = summaryBox.value.replace(xfdregex,'[[WP:PROD]], reason was \'$2\'.');
      return;
   }
   if(summaryBox.value.indexOf('\{\{rfd\}\}') != -1) {
      // best we can do without a direct link
      summaryBox.value = '[[WP:RFD|RFD]]';
      return;
   }
   xfdregex = /.*\{\{((db|delete).*?)\}\}.*/;
   if(xfdregex.test(summaryBox.value))  { // last resort for unhandled speedy tags
      summaryBox.value = summaryBox.value.replace(xfdregex,'$1');
      return;
   }
  }
  addEvent(list, "change", csdChangeBox, false);
  autopick_deletion_reason();
  })(); // scope
 }

// Sensitive IP checker - maintained by east718
if (wgPageName == 'Special:BlockIP')
{
	ips = Array(
		Array(/\b63\.162\.143\.21\b/, 'the [[United States Department of Homeland Security|U.S. Department of Homeland Security]]'),
		Array(/\b82\.148\.9(6\.68|7\.69)\b/, '[[Qatar|Qatar]]'),
		Array(/\b128\.183\.103\.97\b/, '[[NASA|NASA]]'),
		Array(/\b(((2|5)?6|7|[12]1|2(2|8|9)|3(0|3)|55)\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))|130\.22|)(\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}\b/, 'the [[United States Department of Defense|U.S. Department of Defense]]'),
		Array(/\b138\.16[23](\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}\b/, 'the [[United States Navy|U.S. Naval Telecommunications Station]]'),
		Array(/\b143\.2(2[89]|3[01])(\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}\b/, 'the [[United States House of Representatives|U.S. House of Representatives]]'),
		Array(/\b149\.101(\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}\b/, 'the [[United States Department of Justice|U.S. Department of Justice]]'),
		Array(/\b156\.33(\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}\b/, 'the [[United States Senate|U.S. Senate]]'),
		Array(/\b(162\.4[56]\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))|198\.81\.(128|129|1[3-8]\d|191))\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))\b/, 'the [[Central Intelligence Agency|U.S. Central Intelligence Agency]]'),
		Array(/\b192\.197\.(7[7-9]|8[0-6])\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))\b/, 'the [[Government of Canada|Government of Canada]]'),
		Array(/\b(51(\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))){2}|194.60.\d[0-5]?)\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))\b/, 'the [[Parliament of the United Kingdom|U.K. Parliament]]'),
		Array(/\b66\.230\.(19[2-9]|2[0-3]\d)\.([01]?\d{2}?|2(5[0-5]|[0-4]\d))\b/, 'the [[Wikimedia Foundation|Wikimedia secure gateway]]'),
		Array(/\b91\.198\.174\.(19[2-9]|2([01]\d|2[0-3]))\b/, 'the [[m:Toolserver|Wikimedia Toolserver]]')
	);
	ip = document.getElementById('mw-bi-target').value;
	if (/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/.test(ip))
	{
		for (i = 0; i < ips.length; i++)
		{
			if (ip.match(ips[i][0]))
			{
				jsMsg('<table><tr><td valign="center"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Nuvola_apps_important.svg/48px-Nuvola_apps_important.svg.png" /></td><td valign="center">You are blocking a sensitive IP address belonging to ' + ips[i][1].replace('[[', '<a href="http://en.wikipedia.org/wiki/').replace('|', '">').replace(']]', '</a>') + '. Please be sure to <a href="http://meta.wikimedia.org/wiki/Communications_committee/Notifications" class="extiw" title="meta:Communications_committee/Notifications">notify</a> the <a href="http://meta.wikimedia.org/wiki/Communications_committee" class="extiw" title="meta:Communications_committee">Wikimedia Foundation Communications Committee</a> immediately.</td></tr></table>');
			}
		}
	}
}