User:Frietjes/CAT.js

jQuery(document).ready(function($) {

if(mw.config.get('wgNamespaceNumber') != -1) { mw.loader.using(['mediawiki.util']).done( function {		var portletlink = mw.util.addPortletLink('p-tb','#','Add categories','t-catit');		$(portletlink).click(function(e) { e.preventDefault; catscriptfunction; });	}); } // // function catscriptfunction { var myContent = document.getElementById('wpTextbox1').value;

// add noinclude section if it's not there if( myContent.search(/ /g) < 0 ) { myContent = myContent + ' \n '; } while(myContent.match(/ /g).length > 1) { myContent = myContent.replace(/(<)(noinclude>)/, '$1 $2'); } if( myContent.search(/\[\[Category/gi) < 0 ) { myContent = myContent.replace(//, '$1\n[[Category:]]'); } if( myContent.search(/[Ss]ports[_ ]+table/g) >= 0) { myContent = myContent.replace(/(\[\[Category:)(\]\])/g, '$1Association football standings templates$2'); } myContent = myContent.replace(/(<) (noinclude>)/g, '$1$2'); if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value = myContent; document.getElementById('wpSummary').value = 'add categories'; } } // // });