User:WOSlinker/remove.js

function remove_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 'remove edit' tab if(mw.config.get('wgArticleId') != 0 ) { $( function removeEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',remove:true}), 'remove', 'p-remove', 'remove edit');   } )}

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

var matches1 = myContent.match(/\\<\/div\> *\n/gi,'\n'); myContent = myContent.replace(/\n *\<\/div\> *\n/gi,'\n'); myContent = myContent.replace(/\<\/div\>/gi,''); };

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='remove unused closing div tag'; document.getElementById('wpMinoredit').checked = true; }

if(document.getElementById('wpTextbox1').value == myContent) { var matches1 = myContent.match(/\ *\n/gi,'\n'); myContent = myContent.replace(/\<\/center\>/gi,''); };

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='remove unused closing center tag'; document.getElementById('wpMinoredit').checked = true; }       }

if(document.getElementById('wpTextbox1').value == myContent) { var matches1 = myContent.match(/\ *\n/gi,'\n'); myContent = myContent.replace(/\<\/span\>/gi,''); };

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='remove unused closing span tag'; document.getElementById('wpMinoredit').checked = true; }       }

if(document.getElementById('wpTextbox1').value == myContent) { var matches1 = myContent.match(/\ *\n/gi,'\n'); myContent = myContent.replace(/\<\/small\>/gi,''); };

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='remove unused closing small tag'; document.getElementById('wpMinoredit').checked = true; }       }

} )}

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

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

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

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='tidy wikitable options'; document.getElementById('wpMinoredit').checked = true; }

} )}