User:EvergreenFir/common.js

Source: Wikipedia, the free encyclopedia.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//Edit reqeust helper
importScript('User:Jackmcbarn/editProtectedHelper.js'); // Linkback: [[User:Jackmcbarn/editProtectedHelper.js]]
importScript('User:Ohconfucius/script/Common Terms.js'); // [[User:Ohconfucius/script/Common Terms.js]]
/* User:Technical_13/Scripts/OneClickArchiver */
importScript( 'User:Technical_13/Scripts/OneClickArchiver.js' ); // Backlink: [[User:Technical_13/Scripts/OneClickArchiver]]
//Makes identifying blocked editors instantaneous.
importScript('User:NuclearWarfare/Mark-blocked script.js'); // Linkback: [[User:NuclearWarfare/Mark-blocked script.js]]
// Response Helper 
importScript('User:MusikAnimal/responseHelper.js');
//Mass revdel
importScript('User:Writ_Keeper/Scripts/massRevdel.js');
//ReFill
mw.loader.load( "https://meta.wikimedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );
//Identifying admins
//importScript('User:Theopolisme/Scripts/adminhighlighter.js');
//SPI Helper
mw.loader.load( '/w/index.php?title=User:GeneralNotability/spihelper.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:GeneralNotability/spihelper.js]]
//Mass rollback
//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' ).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', '#', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here");
			$("#ca-rollbackeverything").click( function(event)
			{
				event.preventDefault();
				mw.loader.load( 'mediawiki.api' ); //start loading, while the user is in the prompt	
				return rollbackEverythingWKMR(prompt("Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the rollback entirely)"));
			});
		});
	}
});

//Socks button
$( document ).ready( function() {
  mw.util.addPortletLink(
    'p-personal',
    mw.util.getUrl('User:EvergreenFir/socks'),
    'Socks',
    null,
    '#pt-preferences'
  );
});

//<nowiki>
/**
 * Admin highlighter 2.0
 * ---------------------
 * A jQuery/mediawiki-heavy rewrite of [[User:Amalthea/userhighlighter.js]]
 * 
 * This script highlights links to admins' userpages or talkpages in bodyContent
 * (that is, everything but the tabs, personal links at the top of the screen and sidebar)
 * by giving them a cyan background.
 *
 * See [[User:Theopolisme/Scripts/adminhighlighter]] for more details.
 *
 * @author theopolisme
 */
;(function($, mw){
	$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Amalthea_(bot)/userhighlighter.js/sysop.js', function(data){
		ADMINHIGHLIGHT_EXTLINKS = window.ADMINHIGHLIGHT_EXTLINKS || false;
		ADMINHIGHLIGHT_NAMESPACES = [-1,2,3];
		mw.loader.using(['mediawiki.util','mediawiki.Uri', 'mediawiki.Title'], function() {
			mw.util.addCSS(".userhighlighter_sysop.userhighlighter_sysop {text-decoration:underline !important}");
			$('#bodyContent a').each(function(index,linkraw){
				try {
					var link = $(linkraw);
					var url = link.attr('href');
					if (!url || url.charAt(0) === '#') return; // Skip <a> elements that aren't actually links; skip anchors
					if (url.lastIndexOf("http://", 0) != 0 && url.lastIndexOf("https://", 0) != 0 && url.lastIndexOf("/", 0) != 0) return; //require http(s) links, avoid "javascript:..." etc. which mw.Uri does not support
					var uri = new mw.Uri(url);
					if (!ADMINHIGHLIGHT_EXTLINKS && !$.isEmptyObject(uri.query)) return; // Skip links with query strings if highlighting external links is disabled
					if (uri.host == 'en.wikipedia.org') {
						var mwtitle = new mw.Title(mw.util.getParamValue('title',url) || decodeURIComponent(uri.path.slice(6))); // Try to get the title parameter of URL; if not available, remove '/wiki/' and use that
						if ($.inArray(mwtitle.getNamespaceId(), ADMINHIGHLIGHT_NAMESPACES)>=0) {
							var user = mwtitle.getMain().replace(/_/g," ");
							if (mwtitle.getNamespaceId() === -1) user = user.replace('Contributions/',''); // For special page "Contributions/<username>"
							if (data[user] == 1) {
								link.addClass('userhighlighter_sysop'); // Override the above color by using `a.userhighlighter_sysop.userhighlighter_sysop {background-color: COLOR !important}`
							}
						}
					}
				} catch (e) {
					// Sometimes we will run into unparsable links, so just log these and move on
					window.console && console.error('Admin highlighter recoverable error',e.message);
				}
			});
		});
	});
}(jQuery, mediaWiki));
//</nowiki>