User:UrbanToreador/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.
importScript('User:קיפודנחש/pageCollector.js');
// list of "todo" pages and button legends for PageCollector
var pagesToCollect = [
	{page: 'User:Schazjmd/useful links', caption: 'Save link'}
];

// load pageCollector script:
importScript('User:קיפודנחש/pageCollector.js');
//importScript('User:Theopolisme/Scripts/adminhighlighter.js');
//mw.loader.load('//en.wikipedia.org/w/index.php?title=User%3ATheopolisme%2FScripts%2Fadminhighlighter.js&action=raw&ctype=text/javascript');

importScript('User:Jackmcbarn/editProtectedHelper.js'); // Linkback: [[User:Jackmcbarn/editProtectedHelper.js]]

importScript('User:GregU/dashes.js');

// install reply-link
importScript( 'User:Enterprisey/reply-link.js' ); // Backlink: [[User:Enterprisey/reply-link.js]]

// install page curation
importScript('User:Lourdes/PageCuration.js'); // Linkback: [[User:Lourdes/PageCuration.js]]

// install archiver
importScript( 'User:Σ/Testing facility/Archiver.js' ); // Backlink: [[User:Σ/Testing facility/Archiver]]

// install highlighter script
importScript("User:PleaseStand/highlight-comments.js");

// install superlinks script
importScript( 'User:Bradv/Scripts/Superlinks.js' ); // Backlink: [[User:Bradv/Scripts/Superlinks.js]]

// install copyvio check
importScript( 'User:DannyS712/copyvio-check.js' ); // Backlink: [[User:DannyS712/copyvio-check.js]]

/* Adds a link in 'more' to do a copyvio check on the given page. Copy of User:The Earwig/copyvios.js, 
but with a different link location (in the same place as other NPP scripts), and opens in a new tab rather than the current window */

mw.loader.using("mediawiki.util", function() {
    mw.util.addPortletLink(
        "p-cactions",
        "https://tools.wmflabs.org/copyvios/?lang=" + mw.config.get("wgContentLanguage") + "&project=" + mw.config.get("wgSiteName").toLowerCase() + "&title=" + encodeURIComponent(mw.config.get("wgPageName")),
        "Copyvio check",
        "t-copyvio-check",
        "Check this page for copyright violations"
    );
});
$("#t-copyvio-check > a").attr("target", "_blank");

//enterprisey revdel tool
importScript( 'User:Enterprisey/cv-revdel.js' ); // Backlink: [[User:Enterprisey/cv-revdel.js]]

//delsort tool
importScript( 'User:EnterpriseyBot/delsort.js' ); // Backlink: [[User:EnterpriseyBot/delsort.js]]

//draftify tool
importScript( 'User:Evad37/MoveToDraft.js' ); // Backlink: [[User:Evad37/MoveToDraft]]

//<nowiki>
/**
 * Admin highlighter 3.0
 * ---------------------
 * Derivative of of User:Theopolisme/Scripts/adminhighlighter.js
 * Changes: cache list of admins, and tweak css to use nicer one by Jorm.
 * 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 light background and border.
 *
 * @authors Galobtter, Theopolisme, Amalthea, Ais523
 */
 var main = function(data){
	ADMINHIGHLIGHT_EXTLINKS = window.ADMINHIGHLIGHT_EXTLINKS || false;
	ADMINHIGHLIGHT_NAMESPACES = [-1,2,3];
	mw.loader.using(['mediawiki.util','mediawiki.Uri', 'mediawiki.Title']).then(function() {
		mw.util.addCSS(
		"a.userhighlighter_sysop { background-color: rgba(100, 149, 237, 0.25) !important; border-top: .05em dashed rgba(100, 149, 237, 0.5); border-bottom: .05em dashed rgba(100, 149, 237, 0.5); }"+
		"a.userhighlighter_sysop.mw-changeslist-title { background-color: transparent !important; border-color: transparent !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
				console.error('Admin highlighter recoverable error',e.message);
			}
		});
	});
};
// Cache the admin json for a period of time
try {
	var data = JSON.parse(localStorage.getItem('adminjson'));
} catch(e) {
	console.error('Admin highlighter: failed to parse cached admin json object', e.message);
}
if (!data || !data.date || (Date.now() - data.date) > 43200000) { // 12 hours in milliseconds
	$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Amalthea_(bot)/userhighlighter.js/sysop.js').then(
		function(data) {
			data.date = Date.now();
			localStorage.setItem('adminjson', JSON.stringify(data));
			main(data);
		}
	);
} else {
	main(data);
}
//</nowiki>