User:LUUSAP/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin can be added at User:LUUSAP/monobook.css. |
('User:Lupin/recent2.js');
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/core.js&action=raw&ctype=text/javascript'); //Imports the "framework" script needed to make this function
//Sets variable configuration
autoEdTag = "[[WP:CHECKWIKI|Checking Wikipedia]] using [[WP:AutoEd|AutoEd]]"; //Supplies link to CHECKWIKI in summary
autoEdLinkName = "check"; //Changes the link name at the top of the page
autoEdLinkHover = "Run AutoEd to Check Wikipedia"; //When user hovers over link
//Import individual modules for use
//<source lang=javascript>
function autoEdUnicodify(str) { //MAIN FUNCTION describes list of fixes
// Task 1: Replace named html entities with unicode
// Most common replacements
str = str.replace(/—/gi, '—');
// Case insensitive symbols
if(str.search(/&[a-z][a-z]+[0-9]*;/i) >= 0) {
//XML and HTML Symbols
str = str.replace(/…/gi, '...');
str = str.replace(/+/gi, '+');
str = str.replace(/±/gi, '±');
str = str.replace(/−/gi, '−');
str = str.replace(/×/gi, '×');
str = str.replace(/÷/gi, '÷');
str = str.replace(/≠/gi, '≠');
str = str.replace(/≈/gi, '≈');
str = str.replace(/≤/gi, '≤');
str = str.replace(/≥/gi, '≥');
str = str.replace(/"/gi, '"'); // "
str = str.replace(/'/gi, "'"); // '
str = str.replace(/¡/gi, '¡');
str = str.replace(/¢/gi, '¢');
str = str.replace(/£/gi, '£');
str = str.replace(/¤/gi, '¤');
str = str.replace(/¥/gi, '¥');
str = str.replace(/¦/gi, '¦');
str = str.replace(/§/gi, '§');
str = str.replace(/¨/gi, '¨');
str = str.replace(/©/gi, '©');
str = str.replace(/ª/gi, 'ª');
str = str.replace(/«/gi, '«');
str = str.replace(/¬/gi, '¬');
str = str.replace(/®/gi, '®');
str = str.replace(/¯/gi, '¯');
str = str.replace(/°/gi, '°');
str = str.replace(/²/gi, '²');
str = str.replace(/³/gi, '³');
str = str.replace(/´/gi, '´');
str = str.replace(/µ/gi, 'µ');
str = str.replace(/¶/gi, '¶');
str = str.replace(/·/gi, '·');
str = str.replace(/¸/gi, '¸');
str = str.replace(/¹/gi, '¹');
str = str.replace(/º/gi, 'º');
str = str.replace(/»/gi, '»');
str = str.replace(/¼/gi, '¼');
str = str.replace(/½/gi, '½');
str = str.replace(/¾/gi, '¾');
str = str.replace(/¿/gi, '¿');
str = str.replace(/ˆ/gi, 'ˆ');
str = str.replace(/˜/gi, '˜');
str = str.replace(/‘/gi, '‘');
str = str.replace(/’/gi, '’');
str = str.replace(/‚/gi, '‚');
str = str.replace(/“/gi, '“');
str = str.replace(/”/gi, '”');
str = str.replace(/„/gi, '„');
str = str.replace(/•/gi, '•');
str = str.replace(/‰/gi, '‰');
str = str.replace(/‹/gi, '‹');
str = str.replace(/›/gi, '›');
str = str.replace(/‾/gi, '‾');
str = str.replace(/⁄/gi, '⁄');
str = str.replace(/€/gi, '€');
str = str.replace(/ℑ/gi, 'ℑ');
str = str.replace(/℘/gi, '℘');
str = str.replace(/ℜ/gi, 'ℜ');
str = str.replace(/™/gi, '™');
str = str.replace(/ℵ/gi, 'ℵ');
str = str.replace(/↵/gi, '↵');
str = str.replace(/∀/gi, '∀');
str = str.replace(/∂/gi, '∂');
str = str.replace(/∃/gi, '∃');
str = str.replace(/∅/gi, '∅');
str = str.replace(/∇/gi, '∇');
str = str.replace(/∈/gi, '∈');
str = str.replace(/∉/gi, '∉');
str = str.replace(/∋/gi, '∋');
str = str.replace(/∏/gi, '∏');
str = str.replace(/∑/gi, '∑');
str = str.replace(/∗/gi, '∗');
str = str.replace(/√/gi, '√');
str = str.replace(/∝/gi, '∝');
str = str.replace(/∞/gi, '∞');
str = str.replace(/∠/gi, '∠');
str = str.replace(/∧/gi, '∧');
str = str.replace(/∨/gi, '∨');
str = str.replace(/∩/gi, '∩');
str = str.replace(/∪/gi, '∪');
str = str.replace(/∫/gi, '∫');
str = str.replace(/∴/gi, '∴');
str = str.replace(/∼/gi, '∼');
str = str.replace(/≅/gi, '≅');
str = str.replace(/⊂/gi, '⊂');
str = str.replace(/⊃/gi, '⊃');
str = str.replace(/⊄/gi, '⊄');
str = str.replace(/⊆/gi, '⊆');
str = str.replace(/⊇/gi, '⊇');
str = str.replace(/⊕/gi, '⊕');
str = str.replace(/⊗/gi, '⊗');
str = str.replace(/⊥/gi, '⊥');
str = str.replace(/⋅/gi, '⋅');
str = str.replace(/⌈/gi, '⌈');
str = str.replace(/⌉/gi, '⌉');
str = str.replace(/⌊/gi, '⌊');
str = str.replace(/⌋/gi, '⌋');
str = str.replace(/⟨/gi, '〈');
str = str.replace(/⟩/gi, '〉');
str = str.replace(/◊/gi, '◊');
str = str.replace(/♠/gi, '♠');
str = str.replace(/♣/gi, '♣');
str = str.replace(/♥/gi, '♥');
str = str.replace(/♦/gi, '♦');
}
// Uppercase symbols
if(str.search(/&[A-Z][a-z]+;/) >= 0) {
//Greek symbols
str = str.replace(/Α/g, 'Α');
str = str.replace(/Β/g, 'Β');
str = str.replace(/Γ/g, 'Γ');
str = str.replace(/Δ/g, 'Δ');
str = str.replace(/Ε/g, 'Ε');
str = str.replace(/Ζ/g, 'Ζ');
str = str.replace(/Η/g, 'Η');
str = str.replace(/Θ/g, 'Θ');
str = str.replace(/Ι/g, 'Ι');
str = str.replace(/Κ/g, 'Κ');
str = str.replace(/Λ/g, 'Λ');
str = str.replace(/Μ/g, 'Μ');
str = str.replace(/Ν/g, 'Ν');
str = str.replace(/Ξ/g, 'Ξ');
str = str.replace(/Ο/g, 'Ο');
str = str.replace(/Π/g, 'Π');
str = str.replace(/Ρ/g, 'Ρ');
str = str.replace(/Σ/g, 'Σ');
str = str.replace(/Τ/g, 'Τ');
str = str.replace(/Υ/g, 'Υ');
str = str.replace(/Φ/g, 'Φ');
str = str.replace(/Χ/g, 'Χ');
str = str.replace(/Ψ/g, 'Ψ');
str = str.replace(/Ω/g, 'Ω');
//Latin symbols
str = str.replace(/À/g, 'À');
str = str.replace(/Á/g, 'Á');
str = str.replace(/Â/g, 'Â');
str = str.replace(/Ã/g, 'Ã');
str = str.replace(/Ä/g, 'Ä');
str = str.replace(/Å/g, 'Å');
str = str.replace(/Æ/g, 'Æ');
str = str.replace(/Ç/g, 'Ç');
str = str.replace(/È/g, 'È');
str = str.replace(/É/g, 'É');
str = str.replace(/Ê/g, 'Ê');
str = str.replace(/Ë/g, 'Ë');
str = str.replace(/Ì/g, 'Ì');
str = str.replace(/Í/g, 'Í');
str = str.replace(/Î/g, 'Î');
str = str.replace(/Ï/g, 'Ï');
str = str.replace(/Ñ/g, 'Ñ');
str = str.replace(/Ò/g, 'Ò');
str = str.replace(/Ó/g, 'Ó');
str = str.replace(/Ô/g, 'Ô');
str = str.replace(/Õ/g, 'Õ');
str = str.replace(/Ö/g, 'Ö');
str = str.replace(/Ø/g, 'Ø');
str = str.replace(/Ù/g, 'Ù');
str = str.replace(/Ú/g, 'Ú');
str = str.replace(/Û/g, 'Û');
str = str.replace(/Ü/g, 'Ü');
str = str.replace(/Ý/g, 'Ý');
str = str.replace(/Š/g, 'Š');
str = str.replace(/Ÿ/g, 'Ÿ');
//XML and HTML Symbols
str = str.replace(/‡/g, '‡');
str = str.replace(/″/g, '″');
}
// lowercase symbols
if(str.search(/&[a-z][a-z]+;/) >= 0) {
//Greek symbols
str = str.replace(/α/g, 'α');
str = str.replace(/β/g, 'β');
str = str.replace(/γ/g, 'γ');
str = str.replace(/δ/g, 'δ');
str = str.replace(/ε/g, 'ε');
str = str.replace(/ζ/g, 'ζ');
str = str.replace(/η/g, 'η');
str = str.replace(/θ/g, 'θ');
str = str.replace(/ι/g, 'ι');
str = str.replace(/κ/g, 'κ');
str = str.replace(/λ/g, 'λ');
str = str.replace(/μ/g, 'μ');
str = str.replace(/ν/g, 'ν');
str = str.replace(/ξ/g, 'ξ');
str = str.replace(/ο/g, 'ο');
str = str.replace(/π/g, 'π');
str = str.replace(/ρ/g, 'ρ');
str = str.replace(/ς/g, 'ς');
str = str.replace(/σ/g, 'σ');
str = str.replace(/τ/g, 'τ');
str = str.replace(/υ/g, 'υ');
str = str.replace(/φ/g, 'φ');
str = str.replace(/χ/g, 'χ');
str = str.replace(/ψ/g, 'ψ');
str = str.replace(/ω/g, 'ω');
str = str.replace(/ϑ/g, 'ϑ');
str = str.replace(/ϒ/g, 'ϒ');
str = str.replace(/ϖ/g, 'ϖ');
//Latin symbols
str = str.replace(/ß/g, 'ß');
str = str.replace(/à/g, 'à');
str = str.replace(/á/g, 'á');
str = str.replace(/â/g, 'â');
str = str.replace(/ã/g, 'ã');
str = str.replace(/ä/g, 'ä');
str = str.replace(/å/g, 'å');
str = str.replace(/æ/g, 'æ');
str = str.replace(/ç/g, 'ç');
str = str.replace(/è/g, 'è');
str = str.replace(/é/g, 'é');
str = str.replace(/ê/g, 'ê');
str = str.replace(/ë/g, 'ë');
str = str.replace(/ì/g, 'ì');
str = str.replace(/í/g, 'í');
str = str.replace(/î/g, 'î');
str = str.replace(/ï/g, 'ï');
str = str.replace(/ð/g, 'ð');
str = str.replace(/ñ/g, 'ñ');
str = str.replace(/ò/g, 'ò');
str = str.replace(/ó/g, 'ó');
str = str.replace(/ô/g, 'ô');
str = str.replace(/õ/g, 'õ');
str = str.replace(/ö/g, 'ö');
str = str.replace(/ø/g, 'ø');
str = str.replace(/ù/g, 'ù');
str = str.replace(/ú/g, 'ú');
str = str.replace(/û/g, 'û');
str = str.replace(/ü/g, 'ü');
str = str.replace(/ý/g, 'ý');
str = str.replace(/þ/g, 'þ');
str = str.replace(/ÿ/g, 'ÿ');
str = str.replace(/œ/g, 'œ');
str = str.replace(/š/g, 'š');
str = str.replace(/ƒ/g, 'ƒ');
//XML and HTML Symbols
str = str.replace(/†/g, '†');
str = str.replace(/′/g, '′');
}
// False positives
// Breaks large amounts of code which discuss programming/scripting.
// str = str.replace(/</gi, '<');
// str = str.replace(/>/gi, '>');
// Breaks large number of URLs and discussion of programming/scripting.
// str = str.replace(/&/gi, '&');
// Arrows
str = str.replace(/←/g, '←');
str = str.replace(/→/g, '→');
str = str.replace(/↑/g, '↑');
str = str.replace(/↓/g, '↓');
str = str.replace(/⇐/g, '⇐');
str = str.replace(/⇒/g, '⇒');
str = str.replace(/⇑/g, '⇑');
str = str.replace(/⇓/g, '⇓');
str = str.replace(/↔/g, '↔');
str = str.replace(/⇔/g, '⇔');
str = str.replace(/<==|<--/gi, '←');
str = str.replace(/==>/gi, '→');
// Specific case
str = str.replace(/Ð/g, 'Ð');
str = str.replace(/Þ/g, 'Þ');
str = str.replace(/Œ/g, 'Œ');
// Task 2: Replace numeric html entities with unicode ( User:CharlotteWebb )
// Symbols for which there may be a good reason to obfuscate/escape
var dont_replace = "|!{}[]=<>";
// START specialreplace function from User:CharlotteWebb
function specialreplace(ent, base){
var chr = "";
var num = parseInt(ent.replace(/[\&\#\;x]/g, ''), base);
// see [[UTF-16]] for chars outside the BMP
// try this with Gothic letters at full volume ^_^
if (num > 0xFFFF) {
num -= 0x10000;
chr = String.fromCharCode(0xD800 + (num >> 10), 0xDC00 + (num & 0x3FF));
} else {
chr = String.fromCharCode(num);
}
if (dont_replace.indexOf(chr) == -1) {
str = str.replace(ent, chr, "gi");
}
}
// END specialreplace function
// perform replacement
if(m = str.match(/\&\#(\d+)\;/g)) {
for(i = 0; i < m.length; i++) {
specialreplace(m[i], 10);
}
}
if(m = str.match(/\&\#x([\da-f]+)\;/gi)) {
for(i = 0; i < m.length; i++) {
specialreplace(m[i], 16);
}
}
// Task 3: Unprintable control characters [[Windows-1252]] from User:CharlotteWebb
var failstr = "<!-- AutoEd: rm unicode ctrl char w/no win-1252 mapping, intent unknown -->";
str = str.replace(/\u0080/g, '€');
str = str.replace(/\u0081/g, failstr);
str = str.replace(/\u0082/g, '‚');
str = str.replace(/\u0083/g, 'ƒ');
str = str.replace(/\u0084/g, '„');
str = str.replace(/\u0085/g, '…');
str = str.replace(/\u0086/g, '†');
str = str.replace(/\u0087/g, '‡');
str = str.replace(/\u0088/g, 'ˆ');
str = str.replace(/\u0089/g, '‰');
str = str.replace(/\u008a/g, 'Š');
str = str.replace(/\u008b/g, '‹');
str = str.replace(/\u008c/g, 'Œ');
str = str.replace(/\u008d/g, failstr);
str = str.replace(/\u008e/g, 'Ž');
str = str.replace(/\u008f/g, failstr);
str = str.replace(/\u0090/g, failstr);
str = str.replace(/\u0091/g, '‘');
str = str.replace(/\u0092/g, '’');
str = str.replace(/\u0093/g, '“');
str = str.replace(/\u0094/g, '”');
str = str.replace(/\u0095/g, '•');
str = str.replace(/\u0096/g, '–');
str = str.replace(/\u0097/g, '—');
str = str.replace(/\u0098/g, '˜');
str = str.replace(/\u0099/g, '™');
str = str.replace(/\u009a/g, 'š');
str = str.replace(/\u009b/g, '›');
str = str.replace(/\u009c/g, 'œ');
str = str.replace(/\u009d/g, failstr);
str = str.replace(/\u009e/g, 'ž');
str = str.replace(/\u009f/g, 'Ÿ');
return str;
}
//</source> autoEdUnicodify() converts HTML entities to WikiText
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/isbn.js&action=raw&ctype=text/javascript'); // autoEdISBN() fixes ISBN syntax so that WikiMagic can work
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/whitespace.js&action=raw&ctype=text/javascript'); // autoEdWhitespace() cleans up whitespace
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/wikilinks.js&action=raw&ctype=text/javascript'); // autoEdWikilinks() simplifies and shortens wikilinks where appropriate
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/htmltowikitext.js&action=raw&ctype=text/javascript'); // autoEdHTMLtoWikitext() converts HTML to wikitext
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/headlines.js&action=raw&ctype=text/javascript'); // autoEdHeadlines() fixes common headline errors and renames some headers
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/unicodecontrolchars.js&action=raw&ctype=text/javascript'); // autoEdUnicodeControlChars() converts HTML to wikitext
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/templates.js&action=raw&ctype=text/javascript'); // autoEdTemplates() cleans up templates
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/tablestowikitext.js&action=raw&ctype=text/javascript'); // autoEdTablestoWikitext() replaces HTML tables with wikitables
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/extrabreaks.js&action=raw&ctype=text/javascript'); // autoEdExtraBreaks() removes extra BR tags
mw.loader.load('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/links.js&action=raw&ctype=text/javascript'); // autoEdLinks() cleans up common link errors
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 = autoEdWhitespace(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);
}
//