User:WOSlinkerBot/linttask18.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(/\<span style\=\"color\:blue\"\>\n\:\<center\>([\w\d •,]*)\<\/center\>\<\/span\>/gi,'<center style="color:blue">$1</center>');

          myContent = myContent.replace(/\<sub\>\[\[User\:Thehotwheelsguy99\/Guestbook\|Sign\!\!\<\/sub\>\]\]/g,'<sub>[[User:Thehotwheelsguy99/Guestbook|Sign!!]]</sub>');

          myContent = myContent.replace(/\<sup\>\[\[User talk\: ASDFGH \|talk\?\<\/sup\>\]\]/g,'<sup>[[User talk: ASDFGH |talk?]]</sup>');

          myContent = myContent.replace(/\<span( style\=\"font-size\: 92\%\; line-height\: 1\.2em\;\>\n\* Czech Republic\:)/g,'<div $1');
          myContent = myContent.replace(/\<span( style\=\"font-size\: 92\%\; line-height\: 1\.2em\;\>\n\* Albania\:)/g,'<div $1');
          myContent = myContent.replace(/\<span( style\=\"font-size\: 92\%\; line-height\: 1\.2em\;\>\n\* Australia\:)/g,'<div $1');
          myContent = myContent.replace(/(\* United States\: \[\[2018 National Women\'s Soccer League season\]\] started Mar 24 *\n)\<\/span\>/g,'$1</div>');
          myContent = myContent.replace(/(\* Wales\: \[\[2017-18 Welsh Premier Women\'s Football League\]\] ends May 18 *\n)\<\/span\>/g,'$1</div>');
          myContent = myContent.replace(/(\* United States\: \[\[20\d\d National Women\'s Soccer League season\]\] *\n)\<\/span\>/g,'$1</div>');
          myContent = myContent.replace(/(\<span style\=\"font-size\: 92\%\; line-height\: 1em\;\>)\n(\[\[WP\:GNG\]\] takes precedence over \[\[WP\:NFOOTY\]\])/g,'$1$2');

          myContent = myContent.replace(/\[\[Commons\:User\:ShakataGaNai\|\<span style\=\"color\:\#8B0000\"\>\'\'\'S\'\'\'hakata\'\'\'\<\/span\>\<span style\=\"color\:\#006400\"\>G\'\'\'a\<\/span\>\<span style\=\"color\:\#00008B\"\>\'\'\'N\'\'\'ai\<\/span\>\]\]/g,'[[Commons:User:ShakataGaNai|<span style="color:#8B0000">\'\'\'S\'\'\'hakata</span><span style="color:#006400">\'\'\'G\'\'\'a</span><span style="color:#00008B">\'\'\'N\'\'\'ai</span>]]');

          myContent = myContent.replace(/(\<sup\> \[\[User talk\:Barberio\|talk\]\]\, \[\[Special\:Contributions\/Barberio\|contribs\]\] )\<\/sub\>/g,'$1</sup>');

          myContent = myContent.replace(/\<span style\=\"font-family\: Trebuchet MS\"\>\[\[User talk\:Seadog\.M\.S\|\<font color\=\"Mediumblue\"\>\'\'\'Seadog\'\'\'\]\] \<\/font\>/g,'[[User talk:Seadog.M.S|<span style="font-family:Trebuchet MS;color:Mediumblue;">\'\'\'Seadog\'\'\'</span>]]');

          myContent = myContent.replace(/\<font face\=\"Nasalization\" color\=\"\#003300\"\>\[\[User\:Tennekis\|Tennekis\]\]\<\/font\>/g,'[[User:Tennekis|<span style="font-family:Nasalization;color:#003300;">Tennekis</span>]]');
          myContent = myContent.replace(/\<sup\>\[\[User talk\:Tennekis\|\(rant\)\<\/sup\>\]\]/g,'<sup>[[User talk:Tennekis|(rant)]]</sup>');

          myContent = myContent.replace(/\<font color\=\"black\"\>\'\'\'\[\[User\:Ed\!\|Ed\!\]\]\<\/font\>\<sup\>\<font color\=\"black\"\>\[\[User talk\:Ed\!\|\(talk\)\]\]\'\'\'\<\/font\>\<\/sup\>/g,'\'\'\'[[User:Ed!|<span style="color:black">Ed!</span>]]<sup>[[User talk:Ed!|<span style="color:black">(talk)</span>]]</sup>\'\'\'');


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

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

    }
)}