Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences

For details and instructions about other browsers, see Wikipedia:Bypass your cache.

//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 [[File:pathoschild/templatescript.js]]
 */
// <nowiki>
$.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: '{{Dash}}', 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 '[[Author:'+name+'|'+name+']]';
		});
	}
	
	function portal(editor) {
		editor.replaceSelection(function(name) {
			return '[[Portal:'+name+'|'+name+']]';
		});
	}
	
	function constitution(editor) {
		editor.replaceSelection(function(name) {
			return '[[Constitution of the United States of America|'+name+']]';
		});
	}
	
	function smallcaps(editor) {
		editor.replaceSelection(function(name) {
			return '{{small-caps|'+name+'}}';
		});
	}
	
	function toclink(editor) {
		editor.replaceSelection(function(name) {
			return '{{namespace link|'+name+'|'+name+'|Life and Works of Abraham Lincoln/Volume 8}}';
		});
	}
	
	function wikt(editor) {
		editor.replaceSelection(function(name) {
			return '[[wikt:'+name+'|'+name+']]';
		});
	}
	
	function wp(editor) {
		editor.replaceSelection(function(name) {
			return '[[w:'+name+'|'+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, '<p>')
			.replace(/\n/g, ' ')
			.replace(/<p>/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(/&ndash;/g, '–')
			.replace(/&mdash;/g, '—')
			.replace(/--/g, '—');
	}
	
	function superscript(editor) {
		// Add superscript to selected text
		editor.replaceSelection(function(name) {
			return '<sup>'+name+'</sup>';
		});
	}
	
	// RunningHeader() - puts {{RunningHeader}} in to headerbox
	function RunningHeader(editor) {
		editor.forField('#wpHeaderTextbox').append('\n{{RunningHeader|||}}');
	}
});
// </nowiki>