The Bandersnatch code.

AutoEd

edit

Use the following code with care. It applies the fixes for the CheckWiki module of AutoEd. Take extra care to avoid violating wp:COSMETIC and WP:MEATBOT.

var AutoEd_baseurl = 'http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=Wikipedia:AutoEd/';
if (location.protocol === 'https:') {
  AutoEd_baseurl = 'https://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=Wikipedia:AutoEd/';
}

mw.loader.load(AutoEd_baseurl + 'core.js'); //Imports the "framework" script needed to make this function

//Sets variable configuration
summ = "[[WP:CHECKWIKI|Checking Wikipedia]] using [[WP:AutoEd|AutoEd]] (via [[de:Benutzer:Schnark/js/bandersnatch|Bandersnatch]])"; //Supplies link to CHECKWIKI in summary

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

var txt = oldText;
txt = autoEdUnicodify(txt);
txt = autoEdISBN(txt);
txt = autoEdWikilinks(txt);
txt = autoEdHTMLtoWikitext(txt);
txt = autoEdHeadlines(txt);
txt = autoEdUnicodeControlChars(txt);
txt = autoEdTemplates(txt);
txt = autoEdTablestoWikitext(txt);
txt = autoEdExtraBreaks(txt);
txt = autoEdLinks(txt);
return {text: txt, summary: summ, minor: true}

CW Error #44

var loopcount = 0;
while( oldText.search(/^[=]{1,5}[^=\r\n]*'''[^=\r\n]*[=]{1,5}/gim) >= 0 && loopcount <= 10 ) {
oldText = oldText.replace(/(^[=]{1,5}[^=\r\n]*)'''([^=\r\n]*[=]{1,5})[\t ]*/gim, '$1$2');
loopcount++;
}
summ = "Debolded section per ([[Wikipedia:WikiProject Check Wikipedia/List of errors#44|CW Error #44]]) (via [[de:Benutzer:Schnark/js/bandersnatch|Bandersnatch]])"
return {text: oldText, summary: summ, minor: true}

CW Error #48

function escapeRegExp(string) {
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
firstChar = title.charAt(0); // Get first character of title
lcFirstChar = firstChar.toLowerCase(); // Lowercase first character of title
restOfTitle = escapeRegExp(title.slice(1)); // Rest of title
titleRegexpString = '[' + escapeRegExp(firstChar) + escapeRegExp(lcFirstChar) + ']' + restOfTitle; // Build regexp for title with case-insensitive first letter
titleRegexpString = titleRegexpString.replace(/ /, "[ _]") // Match spaces and underscores
oldText = oldText.replace(new RegExp('\\[\\[ *(' + titleRegexpString + ') *\\]\\]', 'g'), '$1') // Matches [[title]]
oldText = oldText.replace(new RegExp('\\[\\[ *(?:' + titleRegexpString + ') *\\| *([^\\|\\[\n]+?)\\]\\]', 'g'), '$1') // Matches [[title|piped link]]
oldText = oldText.replace(new RegExp('\\[\\[ *(?:' + titleRegexpString + ')#([^\\|\\[\n]+?) *\\]\\]', 'g'), '{{Section link||$1}}') // Matches [[Title#section]]
oldText = oldText.replace(new RegExp('\\[\\[ *#([^\\|]+?) *\\]\\]', 'g'), '{{Section link||$1}}') // Matches [[#section]]
summ = "Removed [[Help:Self link|link(s) to title]] ([[Wikipedia:WikiProject Check Wikipedia/List of errors#48|CW Error #48]]) (via [[de:Benutzer:Schnark/js/bandersnatch|Bandersnatch]])"
return {text: oldText, summary: summ, minor: true, bot:true};

CW Error #86

oldText = oldText.replace( /\[+ *(https?:\/\/[^\n[\]]*?) *\]+/gi, '[$1]' );
summ = "Removed double brackets in external links ([[Wikipedia:WikiProject Check Wikipedia/List of errors#48|CW Error #48]]) (via [[de:Benutzer:Schnark/js/bandersnatch|Bandersnatch]])"
return {text: oldText, summary: summ, minor: true}