User:WOSlinker/nocat.js

if(mw.config.get('wgAction') == 'edit' && queryString('nocat') == 'true') { $(function WOSnocat {       var idx1 = 0;        var idx2 = 0;        var idx3 = 0;        var uc     = ;        var uc1    = ;        var uc2    = ;        var ucall   = ;        var myContent = document.getElementById('wpTextbox1').value;

idx1 = myContent.indexOf("usercategory"); idx3 = myContent.indexOf("\| nocat \="); if (!(idx3 > 0) ) { if (idx1 > 0 ) { idx2 = myContent.indexOf("usercategory2"); if (idx2 > 0) { idx1 = idx2 }; idx2 = myContent.indexOf("\n",idx1);

myContent = myContent.substring(0,idx2+1)+"\| nocat \= \{\{\{nocat\|\}\}\}"+myContent.substring(idx2,myContent.length);

document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='add nocat option'; };       };

if ( !(idx1 > 0) ) { //Find cats idx1 = myContent.indexOf("includeonly"); if( idx1 > 0 ) { idx2 = myContent.indexOf("/includeonly",idx1); uc = myContent.substring(idx1+10,idx2); idx1 = uc.indexOf("\[\[Category\:"); if( idx1 > 0 ) { idx2 = uc.indexOf("\]\]",idx1); uc1 = uc.substring(idx1+11,idx2); uc = uc.substring(idx2-1,uc.length); idx1 = uc1.indexOf("\|"); if( idx1 > 0 ) { uc1 = uc1.substring(0,idx1) }; };              idx1 = uc.indexOf("\[\[Category\:"); if( idx1 > 0 ) { idx2 = uc.indexOf("\]\]",idx1); uc2 = uc.substring(idx1+11,idx2); idx1 = uc2.indexOf("\|"); if( idx1 > 0 ) { uc2 = uc2.substring(0,idx1) }; };           };            if ( uc1 != '' ) { ucall = '\| usercategory  = '+uc1+'\n' } ; if ( uc2 != '' ) { ucall = ucall + '\| usercategory2 = '+uc2+'\n' } ; if ( ucall != '' ) { ucall = ucall + '\| nocat = \{\{\{nocat\|\}\}\}\n';

idx1 = myContent.indexOf("\}\}\<"); if (idx1 > 0 ) { myContent = myContent.substring(0,idx1)+ucall+myContent.substring(idx1,myContent.length); } else {myContent = myContent + '\n' + ucall; } ;

document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='tidy cats';

};

};   } )}