Jump to content

User:WOSlinkerBot/linttask16.js

From Wikipedia, the free encyclopedia
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.
function lint_queryString(p) {
    var re = RegExp('[&?]' + p + '=([^&]*)');
    var matches;
    if (matches = re.exec(document.location)) {
        try { 
            return decodeURI(matches[1]);
        } catch (e) { }
    }
    return null;
}

//Add a 'lint edit' tab
if(mw.config.get('wgArticleId') != 0 ) { 
    $( function lintEditButton() {
        mw.util.addPortletLink('p-cactions', 
                       mw.util.getUrl(null,{action:'edit',lintedit:true}),
                       'lint',
                       'p-lint',
                       'lint edit');
    }
)}

if(mw.config.get('wgAction') == 'edit' && lint_queryString('lintedit') == 'true') {
    $(function lint() {
        var myContent = document.getElementById('wpTextbox1').value;

          myContent = myContent.replace(/\n\{\|(\n\*Check out some of these pages\:\n)/gi,'$1');
          myContent = myContent.replace(/(\|Things to work on at Wikipedia\]\])\n\|\}(\n*\*If you have a question)/gi,'$1$2');
          myContent = myContent.replace(/(\|Manual of Style\]\])\n\|\}(\n*\*If you have a question)/gi,'$1$2');

          myContent = myContent.replace(/\nv(\{\{Episode list\n)/gi,'$1');

          myContent = myContent.replace(/\<table\>(\<small\> Created by \[\[Sahibdin\]\] and nominated for Featured Media by \{\{noping\|TheMandarin\}\} \<\/small\>)\<\/table\>/gi,'$1');
          myContent = myContent.replace(/\<center\>\<span style\=\"font-family\: Arial\; font-size\: 12pt\"\>\<font size\=\"18\"\>(WikiProject India)\<\/center\>\<\/font\>\<\/span\>/gi,'<center><span style="font-family:Arial; font-size:xxx-large;">$1</span></center>');
          myContent = myContent.replace(/(opt-out of future mailings\.<\/small>\}\}\n<\/div>\n)<\/div>(--\[\[User\:MediaWiki message delivery\|MediaWiki message delivery\]\])/gi,'$1$2');

          myContent = myContent.replace(/\<table\>(\<small\> Created by \{\{noping\|Bellus Delphina\}\} \<\/small\>)\<\/table\>/gi,'$1');
          myContent = myContent.replace(/\<center\>\<span style\=\"font-family\: Arial\; font-size\: 12pt\"\>\<font size\=\"18\"\>(WikiProject India)\<\/font\>\<\/span\>\<\/center\>/gi,'<center><span style="font-family:Arial; font-size:xxx-large;">$1</span></center>');

          myContent = myContent.replace(/(\=\= You are Invited to Bangla Wikipedia Photography Contest 2014\! \=\=\n*)\{\| width\=\"100\%\" cellpadding\=\"2\" cellspacing\=\"5\"\n(\<div style)/gi,'$1$2');
          myContent = myContent.replace(/(\(UTC\)\<\/small\>\n)\|\}\n(\<\/div\>\n)/gi,'$1$2');

          myContent = myContent.replace(/\<table width\=\"450\" border\=\"0\" cellspacing\=\"0\" cellpadding\=\"0\" align\=\"center\"\>\n(\<div style\=\"font-family\:Lancelot\;font-size\:80px\;color\:#ffffff\;text-align\:center\;\"\> \<p\>\{\{underline\|\'\'\'\<big\>I\<\/big\>CHTHUS\'\'\'\}\}\<\/p\>\<\/div\>\n)\<\/table\>/gi,'$1');
          myContent = myContent.replace(/\<table width\=\"450\" border\=\"0\" cellspacing\=\"0\" cellpadding\=\"0\" align\=\"center\"\>\n(\<center\>\n\<span style\=\"font-family\: Bebas Neue \; color\:\#ffffff\; font-size\:56pt\;text-align\:center\;\"\><p\>\{\{underline\|\'\'\'\<big\>I\<\/big\>CHTHUS\'\'\'\}\}\<\/p\>\<\/span\>\<\/center\>\n)\<\/table\>/gi,'$1');
          myContent = myContent.replace(/(which drives a wedge into the world of false assurances\.\")(<br>\n)(~ \[\[Jacques Ellul\]\]\'\'\'<\/div>)/gi,'$1\'\'\'$2\'\'\'$3');
          myContent = myContent.replace(/(and may it be sprinkled with love and friendship\.\'\')(<br>\n\'\'\'\'\'Best Wishes\!)/gi,'$1\'\'\'$2');

          myContent = myContent.replace(/\{\| \|- \|\n(\[\[File\:Nuvola apps edu mathematics blue-p\.svg)/gi,'{|\n|$1');

          myContent = myContent.replace(/(\<code\>)\n(\<nowiki\>\=\=References\=\=\<\/nowiki\>)(\n\<br \/\>\n)(\<nowiki\>\{\{Reflist\}\}\<\/nowiki\>)\n(\<\/code\>)/gi,'$1$2$5$3$1$4$5');
          myContent = myContent.replace(/(\<code\>)\n(\<nowiki\>\{\{Refbegin\}\}\<\/nowiki\>)(\n\<br \/\>\n)(\<nowiki\>\*Press paste \(Ctrl\+V or Apple\+V\) after this asterisk, then remove the \<ref\>\<\/ref\> tags\<\/nowiki\>)\n\<br \/\>\n(\<nowiki\>\{\{Refend\}\}\<\/nowiki\>)\n(\<\/code\>)\}\}/gi,'$1$2$6$3$1$4$6$3$1$5$6\n}}');

          if(document.getElementById('wpTextbox1').value != myContent) {

              if(document.getElementById('wpTextbox1').value != myContent) {
                  document.getElementById('wpTextbox1').value=myContent;
                  document.getElementById('wpSummary').value='Fix fostered content [[Special:LintErrors/fostered|lint errors]]';
                  document.getElementById('wpMinoredit').checked = true;
              }
          }

    }
)}