User:OJJ/global.js

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Gadget-WikiLabels-loader.js&action=raw&ctype=text/javascript');

 if ( mw.config.get( 'wgDBname' ) !== 'mediawikiwiki' && mw.config.get( 'wgDBname' ) !== 'commonswiki' && mw.config.get( 'wgDBname' ) !== 'wikidatawiki' && mw.config.get( 'wgDBname' ) !== 'enwiki'&& mw.config.get( 'wgDBname' ) !== 'simplewiki')
 {
    // Morebits, a library for Twinkle-like gadgets by AzaToth
      mw.loader.load('//en.wikipedia.org/w/index.php?title=User:AzaToth/morebits.js&action=raw&ctype=text/javascript');
     
       importScriptURI('//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-markblocked.js&action=raw&ctype=text/javascript');
       importScriptURI('//en.wikipedia.org/w/index.php?title=User:PleaseStand/userinfo.js&action=raw&ctype=text/javascript');

mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:OJJ/beta.js&action=raw&ctype=text/javascript');
 
// This tool can tag pages with a few clicks (which is much faster than editing the whole page per Hand).
// by [[m:user:Hoo man]] <//meta.wikimedia.org/wiki/User:Hoo_man/Scripts/Tagger>
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/tagger.js&action=raw&ctype=text/javascript');
 
var otherSpeedy = {
    'mediawikiwiki': 'speedy',
    'enwikisource': 'sdelete',
    'commonswiki': 'speedy delete',
};
 
var speedyTemplate = "delete";
if (mw.config.get('wgDBname') in otherSpeedy) {
    speedyTemplate = otherSpeedy[mw.config.get('wgDBname')];
}
 
// [[File:Hoo man/tagger.js]]
 
//<nowiki>
if(typeof(taggerConfig) == 'undefined') taggerConfig = {};
taggerConfig.tags = [];
taggerConfig.editSummary = [];
taggerConfig.tags[1] = '{{' + speedyTemplate + '|Vandalismus / Vandalism}}';
taggerConfig.editSummary[taggerConfig.tags[1]] = 'Smazat: Vandalismus / Delete: Vandalism';
taggerConfig.tags[2] = '{{' + speedyTemplate + '|Spam / Spam}}';
taggerConfig.editSummary[taggerConfig.tags[2]] = 'Smazat: Spam / Delete: Spam';
taggerConfig.tags[3] = '{{' + speedyTemplate + '|Mimo rozsah projektu / Out of project scope}}';
taggerConfig.editSummary[taggerConfig.tags[3]] = 'Smazat: Mimo rozsah projektu / Delete: Out of project scope)';
taggerConfig.tags[4] = '{{' + speedyTemplate + '|Neupravitelné / No meaningful content}}';
taggerConfig.editSummary[taggerConfig.tags[4]] = 'Smazat: Neupravitelné / Delete: No meaningful content';
taggerConfig.tags[5] = '{{' + speedyTemplate + '|Nevýznamné / Unimportant}}';
taggerConfig.editSummary[taggerConfig.tags[5]] = 'Smazat: Nevýznamné / Delete: Unimportant';
 
taggerConfig.tags.other = 'This is used for the option you have to select to be able to insert a custom template';
//</nowiki>
mw.loader.load( '//de.wikipedia.org/w/index.php?title=Benutzer:TMg/autoFormatter.js&action=raw&ctype=text/javascript' );

 }

// Mass revdel
$.when( mw.loader.using( 'mediawiki.api' ), $.ready ).then( function()
{
	var api = new mw.Api();
	if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions")
	{
		$("ul.mw-contributions-list").before("<div style='display:inline-block;' id='revdelCP'>Skrytí revizí<input type='button' id='revdelSelectAll' value='Vybrat vše'><input type='button' id='revdelSelectNone' value='Zrušit vybrané položky'>\
<span style='white-space:nowrap;'><input type='checkbox' id='revdelContent' name='revdelOptions' value='content'> skrýt obsah</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='revdelName' name='revdelOptions' value='userName'> skrýt uživatelské jméno</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='revdelComment' name='revdelOptions' value='editSummary'> skrýt shrnutí editace</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='undelContent' name='revdelOptions' value='content'> zviditelnit obsah</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='undelName' name='revdelOptions' value='userName'> zviditelnit uživatelské jméno</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='undelComment' name='revdelOptions' value='editSummary'> zviditelnit shrnutí editace</span> \
<br/><select id='wpRevDeleteReasonList'><option value='other'></option></select><input name='wpReason' size='60' id='wpReason' maxlength='100'>\
<input type='button' class='revdelSubmit' id='revdelSubmit' value='Skrytí vybraných revizí'> <input type='button' class='revdelSubmit' id='oversightSubmit' value='Oversight vybraných revizí'></div>");
		$("ul.mw-contributions-list .mw-revdelundel-link").each(function(ind,el){
			var revId = /ids=(\d+)/.exec($(this).children("a").attr("href"))[1];
			var pageTitle = /target=([^&]+)/.exec($(this).children("a").attr("href"))[1];
			el.innerHTML = "<input type='checkbox' name='"+decodeURIComponent(pageTitle)+"' class='revdelIds' value='"+revId+"'>";
		});
		$("ul.mw-contributions-list").after("</form>");
		
		//load canned summaries
		$.get("/w/index.php?title=MediaWiki:Revdelete-reason-dropdown&action=raw",function(data)
		{
			reasons = data.replace(/\*\* ([^\*]+)/g, '<option value="$1">$1</option>');
			reasons = reasons.replace(/\* ([^<]+)([^\*]+)/g, '<optgroup label="$1">$2</optgroup>');
			$('#wpRevDeleteReasonList').append(reasons);
		});
		
		//attach handlers
		$("#revdelSelectAll").click(
			function()
			{
				$('input.revdelIds').each(function()
				{
					$(this).prop("checked", true);
				})
			}
		);
		$("#revdelSelectNone").click(
			function()
			{
				$('input.revdelIds').each(function()
				{
					$(this).prop("checked", false);
				})
			}
		);
		$("#revdelSubmit").click(
			function()
			{
				//figure out which revisions and pages we're working on.
				var revCount = 0;
				var numTitles = 0;
				var pageTitles = {};
				$("input.revdelIds:checked").each(function(ind)
				{
					revCount = ind + 1;
					if(ind > 49)
					{
						alert("Nelze skrýt více než 50 revizí.");
						return false;
					}
					if(typeof pageTitles[$(this).attr("name")] == "undefined")
					{
						pageTitles[$(this).attr("name")] = $(this).val();
						numTitles++;
					}
					else
					{
						pageTitles[$(this).attr("name")] = pageTitles[$(this).attr("name")] + "|" + $(this).val();
					}
				});
				if(numTitles == 0)
				{
					alert("Nebyla vybrána žádná revize");
					return false;
				}
				var confirmString = "Pokoušíte se skrýt " + revCount + " revizi/revize.\n\nZmění se následující vlasnosti revize:\n";
				
				//figure out what we're doing to each revision. This is pretty clunky, but whatever.
				var deleteString = "";
				var revealString = "";
				var typeString = "revdel";
				
				if($("#revdelContent").prop("checked") == $("#undelContent").prop("checked"))
				{
					confirmString = confirmString + "-Viditelnost obsahu se nezmění\n";
				}
				else if($("#revdelContent").prop("checked"))
				{
					deleteString = "content";
					confirmString = confirmString + "-Obsah bude skryt\n";
				}
				else
				{
					revealString = "content";
					confirmString = confirmString + "-Obsah bude odkryt\n";
				}
				if($("#revdelComment").prop("checked") == $("#undelComment").prop("checked"))
				{
					confirmString = confirmString + "-Viditelnost shrnutí editace se nezmění\n";
				}
				else if($("#revdelComment").prop("checked"))
				{
					if(deleteString != "")
					{
						deleteString = deleteString + "|";
					}
					deleteString = deleteString + "comment";
					confirmString = confirmString + "-Shrnutí editace bude skryto\n";
				}
				else
				{
					if(revealString != "")
					{
						revealString = revealString + "|";
					}
					revealString = revealString + "comment";
					confirmString = confirmString + "-Shrnutí editace bude okryto\n";
				}
				if($("#revdelName").prop("checked") == $("#undelName").prop("checked"))
				{
					confirmString = confirmString + "-Viditelnost uživatelského jména se nezmění\n";
				}
				else if($("#revdelName").prop("checked"))
				{
					if(deleteString != "")
					{
						deleteString = deleteString + "|";
					}
					deleteString = deleteString + "user";
					confirmString = confirmString + "-Uživatelské jméno bude skryto\n";
				}
				else
				{
					if(revealString != "")
					{
						revealString = revealString + "|";
					}
					revealString = revealString + "user";
					confirmString = confirmString + "-Uživatelské jméno bude zviditelněno\n";
				}
				if(deleteString == "" && revealString == "")
				{
					alert("Nebyly vybrány žádné vlasnosti revizí");
					return false;
				}
				
				var summary = "";
				
				//construct the revdel summary
				if($("#wpRevDeleteReasonList").val() == "other")
				{
					if($("#wpReason").val() == "")
					{
						alert("Nebylo vyplněno shrnutí editace");
						return false;
					}
					summary = $("#wpReason").val();
				}
				else
				{
					summary = $("#wpRevDeleteReasonList").val();
					if($("#wpReason").val() != "")
					{
						summary = summary + ": " +  $("#wpReason").val();
					}
				}
				confirmString = confirmString + "\nVaše shrnutí je "+ summary +"\n\nSkrýt?";
				
				if(confirm(confirmString))
				{
					var numCompleted = 0;
					for (title in pageTitles)
					{
						var ajaxData;
						ajaxData = {action:"revisiondelete",type:"revision",ids:pageTitles[title],reason:summary};
						if(deleteString != "")
						{
							ajaxData.hide=deleteString;
						}
						if(revealString != "")
						{
							ajaxData.show=revealString;
						}
						api.postWithToken('csrf', ajaxData).done(function()
						{
							numCompleted++;
							if(numCompleted == numTitles)
							{
								alert("Hotovo!");
								return false;
							}
						});
					}
				}
				return false;
			}
		)
		$("#oversightSubmit").click(
			function()
			{
				//figure out which revisions and pages we're working on.
				var revCount = 0;
				var numTitles = 0;
				var pageTitles = {};
				$("input.revdelIds:checked").each(function(ind)
				{
					revCount = ind + 1;
					if(ind > 49)
					{
						alert("Nelze skrýt více než 50 revizí.");
						return false;
					}
					if(typeof pageTitles[$(this).attr("name")] == "undefined")
					{
						pageTitles[$(this).attr("name")] = $(this).val();
						numTitles++;
					}
					else
					{
						pageTitles[$(this).attr("name")] = pageTitles[$(this).attr("name")] + "|" + $(this).val();
					}
				});
				if(numTitles == 0)
				{
					alert("Nebyla vybrána žádná revize");
					return false;
				}
				var confirmString = "You are attempting to modify " + revCount + " revisions.\n\nThe following revision attributes will be changed:\n";
				
				//figure out what we're doing to each revision. This is pretty clunky, but whatever.
				var deleteString = "";
				var oversighting = -1;
				
				if($("#revdelContent").prop("checked") == $("#undelContent").prop("checked"))
				{
					confirmString = confirmString + "-Content visibility won't change.\n";
				}
				else if($("#revdelContent").prop("checked"))
				{
					deleteString = "content";
					confirmString = confirmString + "-Content will be oversighted.\n";
					oversighting = 1;
				}
				else
				{
					if(oversighting == 1)
					{
						alert("we can't oversight and un-oversight edits at the same time!");
						return false;
					}
					deleteString = "content";
					confirmString = confirmString + "-Content will be returned to normal (admin-only) revision deletion.\n";
					oversighting = 0;
				}
				if($("#revdelComment").prop("checked") == $("#undelComment").prop("checked"))
				{
					confirmString = confirmString + "-Edit summary visibility won't change.\n";
				}
				else if($("#revdelComment").prop("checked"))
				{
					if(oversighting == 0)
					{
						alert("we can't oversight and un-oversight edits at the same time!");
						return false;
					}
					if(deleteString != "")
					{
						deleteString = deleteString + "|";
					}
					deleteString = deleteString + "comment";
					confirmString = confirmString + "-Edit summary will be oversighted.\n";
					oversighting = 1;
				}
				else
				{
					if(oversighting == 1)
					{
						alert("we can't oversight and un-oversight edits at the same time!");
						return false;
					}
					if(deleteString != "")
					{
						deleteString = deleteString + "|";
					}
					deleteString = deleteString + "comment";
					confirmString = confirmString + "-Edit summary will be returned to normal (admin-only) revision deletion.\n";
					oversighting = 0;
				}
				if($("#revdelName").prop("checked") == $("#undelName").prop("checked"))
				{
					confirmString = confirmString + "-User name visibility won't change.\n";
				}
				else if($("#revdelName").prop("checked"))
				{
					if(oversighting == 0)
					{
						alert("we can't oversight and un-oversight edits at the same time!");
						return false;
					}
					if(deleteString != "")
					{
						deleteString = deleteString + "|";
					}
					deleteString = deleteString + "user";
					confirmString = confirmString + "-User name will be oversighted.\n";
					oversighting = 1;
				}
				else
				{
					if(oversighting == 1)
					{
						alert("we can't oversight and un-oversight edits at the same time!");
						return false;
					}
					if(deleteString != "")
					{
						deleteString = deleteString + "|";
					}
					deleteString = deleteString + "user";
					confirmString = confirmString + "-User name will be returned to normal (admin-only) revision deletion.\n";
					oversighting = 0;
				}
				if(deleteString == "")
				{
					alert("Nebyly vybrány žádné vlasnosti revizí");
					return false;
				}
				
				var summary = "";
				
				//construct the revdel summary
				if($("#wpRevDeleteReasonList").val() == "other")
				{
					if($("#wpReason").val() == "")
					{
						alert("Nebylo vyplněno shrnutí editace");
						return false;
					}
					summary = $("#wpReason").val();
				}
				else
				{
					summary = $("#wpRevDeleteReasonList").val();
					if($("#wpReason").val() != "")
					{
						summary = summary + ": " +  $("#wpReason").val();
					}
				}
				confirmString = confirmString + "\nYour oversight summary is: "+ summary +"\n\nOpravdu skrýt?";
				
				if(confirm(confirmString))
				{
					var numCompleted = 0;
					for (title in pageTitles)
					{
						var ajaxData;
						ajaxData = {action:"revisiondelete",type:"revision",ids:pageTitles[title],reason:summary,hide:deleteString};
						if(oversighting == 1)
						{
							ajaxData.suppress = "yes";
						}
						else if(oversighting == 0)
						{
							ajaxData.suppress = "no";
						}
						else
						{
							alert("Chyba");
						}
						api.postWithToken('csrf', ajaxData).done(function()
						{
							numCompleted++;
							if(numCompleted == numTitles)
							{
								alert("modified " + revCount + " úspěšně skryto!");
								return false;
							}
						});
					}
				}
				return false;
			}
		)
	}
});
//Mass rollback function
//Written by John254 and modified/rewritten by Writ Keeper with modifications by TheDJ; original is at https://en.wikipedia.org/wiki/User:John254/mass_rollback.js
//Adapted from User:Mr.Z-man/rollbackSummary.js
//Instructions: Selecting the "rollback all" tab when viewing a user's contributions history
//will open all rollback links displayed there. (Use with caution)
  
function rollbackEverythingWKMR(editSummary) 
{
	if(editSummary === null)
	{
		return false;
	}
	var userName = mw.config.get("wgRelevantUserName");
	var titleRegex = /title=([^&]+)/;
	
	mw.loader.using( 'mediawiki.api.rollback' ).done( function()
	{
		var api = new mw.Api();
		
		$("a[href*='action=rollback']").each(function(ind, el)
		{
			var params = {};
			if( editSummary != '' )
			{
				params.summary = editSummary;
			}
			api.rollback( decodeURIComponent(titleRegex.exec(el.href)[1]), userName, params).done( function()
			{
				$(el).after("reverted");
				$(el).remove();
			} );
		} );
	} );
	return false;
}
$(document).ready(function()
{
	if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions" && $("span.mw-rollback-link").length > 0)
	{
		mw.loader.using("mediawiki.util").done( function ()
		{
			mw.util.addPortletLink('p-cactions', '#', "Hromadný revert", "ca-rollbackeverything", "Rychlý revert všech zde zobrazených editací");
			$("#ca-rollbackeverything").click( function(event)
			{
				event.preventDefault();
				mw.loader.load( [ 'mediawiki.api.rollback' ] ); //start loading, while the user is in the prompt
				return rollbackEverythingWKMR(prompt("Vyplňte shrnutí editace či ponechte prázdné pro automaticky vyplněné shrnutí."));
			});
		});
	}
});
//my patrol
var credible = [];
function showmypatrol(data) {
  $.each(data.query.users, function(k,v) { credible[v.name] = (v.groups && v.groups.indexOf('autopatrolled')!=-1) });
  $('.mw-userlink').each(function () { if(!credible[$(this).text()]) $(this).parent().addClass('not-patrolled'); });
  }
function gomypatrol() {
  var url = 'https://cs.wikipedia.org/w/api.php?action=query&list=users&ususers=' + $('.mw-userlink').map(function(i,v) {return $(this).text();}).toArray().filter(function(v,i,s){ return s.indexOf(v)===i}).join('|') + '&usprop=groups&format=json';
  $.getJSON(url, function(data) { showmypatrol(data); });
  }
function trymypatrol() {
  if(wgCanonicalSpecialPageName == 'Recentchanges' || wgCanonicalSpecialPageName == 'Watchlist') gomypatrol();
  }
$(trymypatrol);