Jump to content

User:ಮಲ್ನಾಡಾಚ್ ಕೊಂಕ್ಣೊ/wikitable attributes.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 wikitable_queryString(p) {
    var re = RegExp('[&?]' + p + '=([^&]*)');
    var matches = re.exec(document.location);
    if (matches) {
        try { 
            return decodeURI(matches[1]);
        } catch (e) { }
    }
    return null;
}

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

if(mw.config.get('wgAction') == 'edit' && wikitable_queryString('wikitableedit') == 'true') {
    $(function wikitable() {
        var myContent = document.getElementById('wpTextbox1').value;
        
        myContent = myContent.replace(/\{\| *border\=\"\d\" *cellpadding\=\"\d*\" *cellspacing\=\"\d*\" *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *border\=\"\d\" *cellspacing\=\"\d*\" *cellpadding\=\"\d*\" *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *border\=\"\d\" *cellpadding\=\"\d*\" *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *border\=\"\d\" *cellspacing\=\"\d*\" *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *cellpadding\=\"\d*\" *cellspacing\=\"\d*\" *border\=\"\d\" *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *cellspacing\=\"\d*\" *cellpadding\=\"\d*\" *border\=\"\d\" *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *cellpadding\=\"\d*\" *cellspacing\=\"\d*\" *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *cellspacing\=\"\d*\" *cellpadding\=\"\d*\" *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *cellspacing\=\"\d*\" *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *cellpadding\=\"\d*\" *class\=\"wikitable/g,'{| class="wikitable');

        myContent = myContent.replace(/\{\| *class\= *\"wikitable sortable sortable\" border\=\"\d\"/g,'{| class="wikitable sortable"');

        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *border\=\"\d\" *cellpadding\=\"\d*\" *cellspacing\=\"\d*\"/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *border\=\"\d\" *cellspacing\=\"\d*\" *cellpadding\=\"\d*\"/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *border\=\"\d\" *cellpadding\=\"\d*\"/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *border\=\"\d\" *cellspacing\=\"\d*\"/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *cellpadding\=\"\d*\" *cellspacing\=\"\d*\" *border\=\"\d\"/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *cellspacing\=\"\d*\" *cellpadding\=\"\d*\" *border\=\"\d\"/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *cellpadding\=\"\d*\" *cellspacing\=\"\d*\"/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *cellspacing\=\"\d*\" *cellpadding\=\"\d*\"/g,'{| class="wikitable sortable"');

        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *border\=\"\d\" *cellpadding\=\"\d*\" *cellspacing\=\"\d*\"/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *border\=\"\d\" *cellspacing\=\"\d*\" *cellpadding\=\"\d*\"/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *border\=\"\d\" *cellpadding\=\"\d*\"/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *border\=\"\d\" *cellspacing\=\"\d*\"/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *cellpadding\=\"\d*\" *cellspacing\=\"\d*\" *border\=\"\d\"/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *cellspacing\=\"\d*\" *cellpadding\=\"\d*\" *border\=\"\d\"/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *cellpadding\=\"\d*\" *cellspacing\=\"\d*\"/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *cellspacing\=\"\d*\" *cellpadding\=\"\d*\"/g,'{| class="wikitable"');


        myContent = myContent.replace(/\{\| *border\=\d *cellpadding\=\d* *cellspacing\=\d* *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *border\=\d *cellspacing\=\d* *cellpadding\=\d* *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *cellspacing\=\d* *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *cellpadding\=\d* *class\=\"wikitable/g,'{| class="wikitable');

        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *border\=\d *cellpadding\=\d* *cellspacing\=\d*/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *border\=\d *cellspacing\=\d* *cellpadding\=\d*/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *border\=\d *cellpadding\=\d*/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *border\=\d *cellspacing\=\d*/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *cellpadding\=\d* *cellspacing\=\d* *border\=\d/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *cellspacing\=\d* *cellpadding\=\d* *border\=\d/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *cellpadding\=\d* *cellspacing\=\d*/g,'{| class="wikitable sortable"');
        myContent = myContent.replace(/\{\| *class *\= *\"wikitable sortable\" *cellspacing\=\d* *cellpadding\=\d*/g,'{| class="wikitable sortable"');

        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *border\=\"\d\" *cellpadding\=\d* *cellspacing\=\d*/g,'{| class="wikitable"');

        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *border\=\d *cellpadding\=\d* *cellspacing\=\d*/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *border\=\d *cellspacing\=\d* *cellpadding\=\d*/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *border\=\d *cellpadding\=\d*/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *border\=\d *cellspacing\=\d*/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *cellpadding\=\d* *cellspacing\=\d* *border\=\d/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *cellspacing\=\d* *cellpadding\=\d* *border\=\d/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *cellpadding\=\d* *cellspacing\=\d*/g,'{| class="wikitable"');
        myContent = myContent.replace(/\{\| *class\=\"wikitable\" *cellspacing\=\d* *cellpadding\=\d*/g,'{| class="wikitable"');

        myContent = myContent.replace(/\{\| *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *class\=\"wikitable/g,'{| class="wikitable');
        myContent = myContent.replace(/\{\| *(border|cellpadding|cellspacing)\=\"?\d*\"? *class\=\"wikitable/g,'{| class="wikitable');

        myContent = myContent.replace(/ (border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *class\=\"wikitable/g,' class="wikitable');
        myContent = myContent.replace(/ (border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *class\=\"wikitable/g,' class="wikitable');
        myContent = myContent.replace(/ (border|cellpadding|cellspacing)\=\"?\d*\"? *class\=\"wikitable/g,' class="wikitable');

        myContent = myContent.replace(/class\=\"wikitable\" *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class="wikitable"');
        myContent = myContent.replace(/class\=\"wikitable\" *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class="wikitable"');
        myContent = myContent.replace(/class\=\"wikitable\" *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class="wikitable"');

        myContent = myContent.replace(/class *\= *\"wikitable sortable\" *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class="wikitable sortable"');
        myContent = myContent.replace(/class *\= *\"wikitable sortable\" *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class="wikitable sortable"');
        myContent = myContent.replace(/class *\= *\"wikitable sortable\" *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class="wikitable sortable"');

        myContent = myContent.replace(/class\=\"sortable wikitable\" *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class="sortable wikitable"');
        myContent = myContent.replace(/class\=\"sortable wikitable\" *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class="sortable wikitable"');
        myContent = myContent.replace(/class\=\"sortable wikitable\" *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class="sortable wikitable"');


        myContent = myContent.replace(/\{\| *class\=wikitable *border\=\"\d\" *cellpadding\=\"\d*\" *cellspacing\=\"\d*\"/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *border\=\"\d\" *cellspacing\=\"\d*\" *cellpadding\=\"\d*\"/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *border\=\"\d\" *cellpadding\=\"\d*\"/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *border\=\"\d\" *cellspacing\=\"\d*\"/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *cellpadding\=\"\d*\" *cellspacing\=\"\d*\" *border\=\"\d\"/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *cellspacing\=\"\d*\" *cellpadding\=\"\d*\" *border\=\"\d\"/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *cellpadding\=\"\d*\" *cellspacing\=\"\d*\"/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *cellspacing\=\"\d*\" *cellpadding\=\"\d*\"/g,'{| class=wikitable');

        myContent = myContent.replace(/\{\| *class\=wikitable *border\=\d *cellpadding\=\d* *cellspacing\=\d*/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *border\=\d *cellspacing\=\d* *cellpadding\=\d*/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *border\=\d *cellpadding\=\d*/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *border\=\d *cellspacing\=\d*/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *cellpadding\=\d* *cellspacing\=\d* *border\=\d/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *cellspacing\=\d* *cellpadding\=\d* *border\=\d/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *cellpadding\=\d* *cellspacing\=\d*/g,'{| class=wikitable');
        myContent = myContent.replace(/\{\| *class\=wikitable *cellspacing\=\d* *cellpadding\=\d*/g,'{| class=wikitable');

        myContent = myContent.replace(/class\=wikitable *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class=wikitable');
        myContent = myContent.replace(/class\=wikitable *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class=wikitable');
        myContent = myContent.replace(/class\=wikitable *(border|cellpadding|cellspacing)\=\"?\d*\"?/g,'class=wikitable');

        myContent = myContent.replace(/ (border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *class\=wikitable/g,' class=wikitable');
        myContent = myContent.replace(/ (border|cellpadding|cellspacing)\=\"?\d*\"? *(border|cellpadding|cellspacing)\=\"?\d*\"? *class\=wikitable/g,' class=wikitable');
        myContent = myContent.replace(/ (border|cellpadding|cellspacing)\=\"?\d*\"? *class\=wikitable/g,' class=wikitable');

        myContent = myContent.replace(/\|\- border\=1 cellspacing\=0 cellpadding\=5\n/g,'');

        myContent = myContent.replace(/(\{\| *class\=\"wikitable plainrowheaders\") (border|cellpadding|cellspacing)\=\"\d*\" (border|cellpadding|cellspacing)\=\"\d*\" (border|cellpadding|cellspacing)\=\"\d*\"/g,'$1');
        myContent = myContent.replace(/(\{\| *class\=\"wikitable plainrowheaders\") (border|cellpadding|cellspacing)\=\"\d*\" (border|cellpadding|cellspacing)\=\"\d*\"/g,'$1');
        myContent = myContent.replace(/(\{\| *class\=\"wikitable plainrowheaders\") (border|cellpadding|cellspacing)\=\"\d*\"/g,'$1');

        myContent = myContent.replace(/\{\| *class\=\"wikitable\" (width\=\"\d*\%\") *cellpadding\=\"\d*\" *cellspacing\=\"\d*\"/g,'{| class="wikitable" $1');

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

              if(document.getElementById('wpTextbox1').value != myContent) {
                  document.getElementById('wpTextbox1').value=myContent;
                  document.getElementById('wpSummary').value='Removed table attributes which are redundant in wikitable class';
                  document.getElementById('wpMinoredit').checked = true;
              }
          }

    }
)}