User:WOSlinkerBot/linttask15.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(/(\[\[image\:Fist-pump\.jpg\|thumb)\|px400(\|Yessss\!)/gi,'$1$2');
          myContent = myContent.replace(/(\[\[File\:SARS-CoV-2 without background.png)\|(\|right\|frameless)\|thumb\|(\]\])/gi,'$1$2$3');
          myContent = myContent.replace(/(\<center\> \'\'\'\[\[Wikipedia\:Meetup\/NYC\/Symposium_on_Wikipedia_and_COVID-19\|Symposium on Wikipedia and COVID-19\]\]\'\'\'\n\:\:)\'\'/gi,'$1');
          myContent = myContent.replace(/(online via \[https\:\/\/www\.youtube\.com\/watch\?v\=E_FzeLUZols YouTube\] and \[https\:\/\/www\.facebook\.com\/wmnyc\/videos\/849530625523461\/ Facebook\])\'\'(\<\/center\>)/gi,'$1$2');
          myContent = myContent.replace(/(\[\[File\:The MET\.jpg)\|right(\|100px\|right\]\])/gi,'$1$2');
          myContent = myContent.replace(/(\[\[File\:HK Sheung Wan Possession Street Hollywood Centre 亞洲藝術文獻庫 Asia Art Archive.JPG)\|right(\|100px\|right\]\])/gi,'$1$2');
          myContent = myContent.replace(/(\[\[File\:Curly Brackets\.svg\|20)x(px\|link\=Help\:Template\#Creating_and_editing_templates\]\])/gi,'$1$2');
          myContent = myContent.replace(/(\[\[Image\:Curly Brackets\.svg\|20)x(px\]\])/gi,'$1$2');

          myContent = myContent.replace(/\n((Image|File)\:[^\|\n]*\|)thumb\|/gi,'\n$1');
          myContent = myContent.replace(/\n((Image|File)\:[^\|\n]*\|[^\|\n]*\|)thumb\|/gi,'\n$1');
          myContent = myContent.replace(/\n((Image|File)\:[^\|\n]*\|[^\|\n]*\|[^\|\n]*\|)thumb\|/gi,'\n$1');

          myContent = myContent.replace(/\n([^\|\n\.\{\[]*\.(jpg|jpeg|png|svg)\|)thumb\|/gi,'\n$1');
          myContent = myContent.replace(/\n([^\|\n\.\{\[]*\.(jpg|jpeg|png|svg)\|[^\|\n]*\|)thumb\|/gi,'\n$1');

          //myContent = myContent.replace(/(File\:Wikipedia Education Program Case Studies \(WMUK version\)\.pdf\|)thumb\|(How universities are teaching with Wikipedia)/g,'$1$2');
          //myContent = myContent.replace(/(File\:Editing Wikipedia brochure \(Wiki Education Foundation\)\.pdf\|)thumb\|(Editing Wikipedia brochure)/g,'$1$2');
          //myContent = myContent.replace(/(File\:Instructor Basics\, How to use Wikipedia as a teaching tool \(Wiki Education Foundation\)\.pdf\|)thumb\|(Instructor Basics\, How to use Wikipedia as a teaching tool)/g,'$1$2');
          //myContent = myContent.replace(/(File\:Illustrating Wikipedia brochure \(Wiki Education Foundation\)\.pdf\|)thumb\|(Illustrating Wikipedia brochure)/g,'$1$2');

          //myContent = myContent.replace(/(\[\[Image\:Original[_ ]Barnstar\.png\|)100px\|(frame\|left\|)/g,'$1$2');
          //myContent = myContent.replace(/(\[\[File\:Original[_ ]Barnstar\.png\|)100px\|(frame\|left\|)/g,'$1$2');

          //myContent = myContent.replace(/(\[\[File\:New medical editor.ogv\|thumb\|right\|thumbtime\=2\:59)\|right(\|320px)/g,'$1$2');

          //myContent = myContent.replace(/ (px\|none)\|left(\]\])/g,'$1$2');
          //myContent = myContent.replace(/(px\|none)\|left(\]\])/g,'$1$2');

          //myContent = myContent.replace(/\|[0-9]*px(\|frame\|left\|)/g,'$1');
          //myContent = myContent.replace(/\|[0-9]*px(\|frame\|right\|)/g,'$1');

          myContent = myContent.replace(/(png\|)100px\|(left\|)The Random-Acts-of-Kindness Barnstar\|(frame\|[A-Za-z0-9 ])/g,'$1$2$3');
          myContent = myContent.replace(/(png\|)100px\|(left\|)The Original Barnstar\|(frame\|[A-Za-z0-9 ])/g,'$1$2$3');
          myContent = myContent.replace(/(png\|)100px\|(left\|)The Working Man\'s Barnstar\|(frame\|[A-Za-z0-9 ])/g,'$1$2$3');
          myContent = myContent.replace(/(png\|)100px\|(left\|)The Editor\'s Barnstar\|(frame\|[A-Za-z0-9 ])/g,'$1$2$3');
          myContent = myContent.replace(/(png\|)100px\|(left\|)The Minor Barnstar\|(frame\|[A-Za-z0-9 ])/g,'$1$2$3');
          myContent = myContent.replace(/(gif\|)100px\|(left\|)The Tireless Contributer Barnstar\|(frame\|[A-Za-z0-9 ])/g,'$1$2$3');
          myContent = myContent.replace(/(png\|)100px\|(left\|)The Barnstar of Diligence\|(frame\|[A-Za-z0-9 ])/g,'$1$2$3');
          myContent = myContent.replace(/(png\|)100px\|(left\|)The Star of Neutrality\|(frame\|[A-Za-z0-9 ])/g,'$1$2$3');

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

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

    }
)}