User:WOSlinker/fb-cat.js

function fbcat_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 'fbcat edit' tab if(mw.config.get('wgNamespaceNumber') == 10 && mw.config.get('wgArticleId') != 0 && mw.config.get('wgPageName').search(/\:Fb/) > 0 ) { $( function fbcatEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',fbcat:true}), 'fbcat', 'p-fbcat', 'fbcat edit');   } )} if(mw.config.get('wgAction') == 'edit' && fbcat_queryString('fbcat') == 'true') { $(function fbcat {       var myContent = document.getElementById('wpTextbox1').value;

if (wgPageName.search(/[ _]team[ _]/) > 0 ) { myContent = myContent + ' \nCategory'+':Fb team templates\n '; } else { if (wgPageName.search(/[ _]competition[ _]/) > 0 ) { myContent = myContent + ' \nCategory'+':Fb competition templates\n '; } else { myContent = myContent + ' \nCategory'+':Fb templates\n '; } };

myContent = myContent.replace(/\<\!\-\-\n\-\-\>\\n\{\{template doc\}\}\n\<\!\-\- Add categories and interwikis to the \/doc subpage, not here\! \-\-\>\n\<\/noinclude\>/,''); myContent = myContent.replace(/\n\ 0 ) { $( function usercatEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',usercat:true}), 'usercat', 'p-usercat', 'usercat edit');   } )}

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

myContent = myContent + ' \n'+ wgPageName.replace(/Template\:User\_/,'').replace(/\_/g,' ') +'\n '; myContent = myContent.replace(/\n\<noinclude/,'<noinclude');

document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='add cat'; document.getElementById('wpMinoredit').checked = true; } )}