Jump to content

User:Quibik/monobook.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.
// --- editing ---
importScript('User:Apoc2400/refToolbarPlus.js'); // [[User:Apoc2400/refToolbarPlus.js]]
importScript('User:Zocky/SearchBox.js'); // [[User:Zocky/SearchBox.js]]
importScript('User:Anomie/ajaxpreview.js'); // [[User:Anomie/ajaxpreview.js]]
importScript('User:Sander Säde/viewsource.js'); // [[User:Sander Säde/viewsource.js]]
importScript('User:Symplectic Map/spell.js'); // [[User:Symplectic Map/spell.js]]

// --- display enhancements ---
importScript('User:Pyrospirit/metadata/projectbanners.js'); // [[User:Pyrospirit/metadata/projectbanners.js]]
//importScript('User:Anomie/linkclassifier.js'); // [[User:Anomie/linkclassifier.js]]
//importStylesheet('User:Anomie/linkclassifier.css'); // [[User:Anomie/linkclassifier.css]]

// --- file descriptions ---
importScript('User:Drilnoth/filescripts.js'); // See [[User:Drilnoth/filescripts.js/doc]] for details
importScript('User:AWeenieMan/furme.js'); // [[User:AWeenieMan/furme.js]]

// --- article tools ---
importScript('User:Pyrospirit/metadata/assesslinks.js'); // [[User:Pyrospirit/metadata/assesslinks.js]]
importScript('User:Anomie/pagestats.js'); // [[User:Anomie/pagestats.js]]
importScript('User:Dr pda/prosesize.js'); // [[User:Dr pda/prosesize.js]]
importScript('User:Sander Säde/assess.js'); // [[User:Sander Säde/assess.js]]

// --- user information ---
importScript('User:Anomie/useridentifier.js'); // [[User:Anomie/useridentifier.js]]
importScript('User:Fran Rogers/dimorphism.js'); // [[User:Fran Rogers/dimorphism.js]]


importScript('User:Lupin/popups.js'); // [[User:Lupin/popups.js]]
popupFixDabs = true;
popupMaxWidth = 500;


// Adds external editing button
$(function() {
	var editTab = document.getElementById("ca-edit");
	if (!editTab) return;
	var editURL = editTab.getElementsByTagName("a")[0].href;
	mw.util.addPortletLink("p-cactions", editURL + "&externaledit=true", "EE", "ca-exted", "External editor", "");
});

/**
 * 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]]
 */
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
	pathoschild.TemplateScript.add([
		// A tool script to correct dash usage in articles.
		{
			name: 'Hyphens → en dash',
			script: function(editor) {
				editor
					.replace(/([^\d\w-]p*\d+|\d+th)\s*(?:[-–—]+|–|—)\s*(\d+[^\d\w-]|present|\d+th)/ig, '$1–$2')
					.replace(/(january|jan|february|feb|march|mar|april|apr|may|june|jun|july|jul|august|aug|september|sept|october|oct|november|nov|December|dec)(?:[-–—]+|–|—)(january|jan|february|feb|march|mar|april|apr|may|june|jun|july|jul|august|aug|september|sept|october|oct|november|nov|December|dec)/gi, '$1–$2')
					.replace(/\s+(?:[-–—]+|–|—)\s+/g, ' – ')
					.setEditSummary('Corrected [[MOS:DASH|dashes]].')
					.clickDiff();
			}
		},
		{
			name: 'en dash (basic)',
			script: function(editor) {
				editor
					.replace(/\s+(?:[-–—]+|–|—)\s+/g, ' – ');
			}
		},
		{
			name: 'name pairs',
			script: function(editor) {
				editor
					.replace(/([A-Z][a-z]+)-([A-Z][a-z]+)/g, '$1–$2')
					.setEditSummary('Corrected [[MOS:DASH|dashes]] in name pairs.')
					.clickDiff();
			}
		}
	]);
});


// AutoEd --------------------------------------------------------------------------------
importScript('Wikipedia:AutoEd/core.js'); //Imports the "framework" script needed to make this function

autoEdTag = "Fixing [[MOS:DASH|dashes]] using [[User:GregU/dashes.js|dashes.js]] and [[WP:AutoEd|AutoEd]]";

//Import individual modules for use
importScript('Wikipedia:AutoEd/unicodify.js'); // autoEdUnicodify() converts HTML entities to WikiText
importScript('Wikipedia:AutoEd/isbn.js'); // autoEdISBN() fixes ISBN syntax so that WikiMagic can work
importScript('Wikipedia:AutoEd/wikilinks.js'); // autoEdWikilinks() simplifies and shortens wikilinks where appropriate
importScript('Wikipedia:AutoEd/htmltowikitext.js'); // autoEdHTMLtoWikitext() converts HTML to wikitext
importScript('Wikipedia:AutoEd/headlines.js'); // autoEdHeadlines() fixes common headline errors and renames some headers
importScript('Wikipedia:AutoEd/unicodecontrolchars.js'); // autoEdUnicodeControlChars() converts HTML to wikitext
importScript('Wikipedia:AutoEd/templates.js'); // autoEdTemplates() cleans up templates
importScript('Wikipedia:AutoEd/tablestowikitext.js'); // autoEdTablestoWikitext() replaces HTML tables with wikitables
importScript('Wikipedia:AutoEd/extrabreaks.js'); // autoEdExtraBreaks() removes extra BR tags
importScript('Wikipedia:AutoEd/links.js'); // autoEdLinks() cleans up common link errors
importScript('User:GregU/dashes.js'); // autoEdDashes() corrects dashes

function autoEdFunctions() { //Activates individual modules when "auto ed" tab is clicked
	var txt = document.editform.wpTextbox1;
	txt.value = autoEdUnicodify(txt.value);
	txt.value = autoEdISBN(txt.value);
	txt.value = autoEdWikilinks(txt.value);
	txt.value = autoEdHTMLtoWikitext(txt.value);
	txt.value = autoEdHeadlines(txt.value);
	txt.value = autoEdUnicodeControlChars(txt.value);
	txt.value = autoEdTemplates(txt.value);
	txt.value = autoEdTablestoWikitext(txt.value);
	txt.value = autoEdExtraBreaks(txt.value);
	txt.value = autoEdLinks(txt.value);
	txt.value = autoEdDashes(txt.value);
}