User:Spangineer/common.js

//importScript('User:Spangineer/Running header.js');

/* Remove Twinkle related JS for now mw.loader.load('//en.wikipedia.org/w/index.php?title=User:AzaToth/morebits.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:AzaToth/twinklefluff.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:AzaToth/twinklediff.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:AzaToth/twinkleprotect.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:AzaToth/twinkleunlink.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:AzaToth/twinklebatchdelete.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:AzaToth/twinklebatchprotect.js&action=raw&ctype=text/javascript'); mw.loader.load('//en.wikipedia.org/w/index.php?title=User:AzaToth/twinklebatchundelete.js&action=raw&ctype=text/javascript'); */

/* Removes "User:Spangineer" from the title */ if(mw.config.get('wgPageName') == 'User:Spangineer') mw.util.addCSS('#siteSub, #contentSub, h1.firstHeading { display: none!important; } #content, #content div.thumb, #p-cactions li a, #p-cactions li a:hover, #p-cactions li.selected a');

/* This script changes the "Your signature with timestamp" edit button to use a real em dash instead of two hyphens. */ (function {	var oldAddButton = window.addButton;	if (typeof(oldAddButton) != 'function') return;	window.addButton = function {		if (arguments.length > 2)			arguments[2] = arguments[2].replace(/^--(~+)$/, '—$1');		oldAddButton.apply(this, arguments);	}; });

/** * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor. * @see https://meta.wikimedia.org/wiki/TemplateScript * @update-token */ // $.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function {	/*********	** Register scripts	*********/	pathoschild.TemplateScript.add([ { name: 'Cleanup', script: cleanup }, { name: 'Rh', script: RunningHeader }, //{ name: 'Rh (lookup)', script: set_running_header }, { name: '', script: dash }, { name: 'Constitution', script: constitution }, { name: 'Author', script: author }, { name: 'Portal', script: portal }, { name: 'small-caps', script: smallcaps }, { name: 'Wikt', script: wikt }, { name: 'Wp', script: wp }, { name: 'TOC link', script: toclink }, { name: 'Superscript', script: superscript } ]);	/*********	** Define scripts	*********/	function author(editor) {		editor.replaceSelection(function(name) { return +name+; });	}	function portal(editor) {		editor.replaceSelection(function(name) { return +name+; });	}	function constitution(editor) {		editor.replaceSelection(function(name) { return +name+; });	}	function smallcaps(editor) {		editor.replaceSelection(function(name) { return ''; });	}	function toclink(editor) {		editor.replaceSelection(function(name) { return ''; });	}	function wikt(editor) {		editor.replaceSelection(function(name) { return +name+; });	}	function wp(editor) {		editor.replaceSelection(function(name) { return +name+; });	}	function cleanup(editor) {		editor			// remove trailing whitespace at the end of each line			.replace(/ \n/g, '\n')			// join words that are hyphenated across a line break			.replace(/-\n/g, )			// remove single line breaks; preserve double.			.replace(/\n{2,}/g, ' ')			.replace(/\n/g, ' ')			.replace(/ /g, '\n\n')			// remove unwanted spaces around punctuation marks			.replace(/ ;/g, ';')			.replace(/ :/g, ':')			.replace(/ \?/g, '?')			.replace(/ !/g, '!')			.replace(/ ,/g, ',')			// convert double-hyphen to mdash			.replace(/--/g, '—')			//simplify quotes			//.replace(/“/g, )			//.replace(/”/g, )			//.replace(/’/g, )			//.replace(/‘/g, '')			// remove spacing around mdash, but only if it has spaces on both sides			// (we don't want to remove the trailing space from "...as follows:— " .replace(/ *— */g, '—') // remove trailing whitespace at end of file .replace(/[ \t\n]+$/, ' ') // OCR fixes: convert i9 to 19, etc.			.replace(/i(?=[0-9])/g, '1') .replace(/l(?=[0-9])/g, '1') .replace(/I-I/g, 'H') .replace(/aUy/g, 'ally') .replace(/iUy/g, 'illy') .replace(/hng/g, 'ling') .replace(/ tlie /g, ' the ') .replace(/labcur/g, 'labour') .replace(/ wlien /g, ' when ') .replace(/ wliat /g, ' what '); }	function dash(editor) { // convert html dashes to characters editor .replace(/–/g, '–') .replace(/&mdash;/g, '—') .replace(/--/g, '—'); }	function superscript(editor) { // Add superscript to selected text editor.replaceSelection(function(name) {			return +name+;		}); }	// RunningHeader - puts in to headerbox function RunningHeader(editor) { editor.forField('#wpHeaderTextbox').append('\n'); } }); //