Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
// Generated by CoffeeScript 2.1.1(function(){/* CATEGORIZE PROMOTED FEATURED ITEMS Description: At [[Wikipedia:Featured articles promoted in 2010]], shows the section from [[Wikipedia:Featured articles]] under where each featured article is placed. */varCategorizePromoted;CategorizePromoted=classCategorizePromoted{staticcategorizePromotedCallback(obj){vararticle,content,heading,matches,page,pageType,pages,section,sections;// Get the first, and should be only, article from the resultspages=obj['query']['pages'];for(pageinpages){article=pages[page];break;}pageType=CategorizePromoted.categorizePromotedPageType();content=article['revisions'][0]['*'];// split "content" by section firstsections={};// Go through [[WP:FA]] to find sections and their contentwhile(content){// 0: whole thing; 1: section title; 2: articles onlymatches=content.match(/\==+(.*?)==+\n([\s\S]*?)\n\n/);heading=matches[1];section=matches[2];sections[heading]=section;content=$.trim(content.replace(matches[0],''));if(!content.match('==')){break;}}return$('#bodyContent').find('.wikitable').each((index,element)=>{var$table,tbody;$table=$(element);tbody=$table.children(':first');// add a new column at the end of the tabletbody.children(':first').append($('<th>Category</th>'));returntbody.children().each((index,element)=>{vararticlePattern,match,results,row;row=$(element);// Only continue if the node is an element and it contains somethingif(!(row[0].nodeType===1&&row.children(':first').children(':first').contents().length)){returntrue;}results=[];for(headinginsections){articlePattern=newRegExp('\\[\\['+CategorizePromoted.escapeRegExp(row.children(':first').text())+'(\\|(.*?))?\\]\\]');match=sections[heading].match(articlePattern);if(match){// Make article title appear based on formatting on WP:FAif(match[2]){row.find('a:first').contents().eq(0).replaceWith(match[2].replace(/''(.*?)''/g,'<i>$1</i>'));}row.append($('<td><a href="'+'/wiki/'+pageType['all']+'#'+encodeURIComponent(heading.replace(/\s/g,'_')).replace(/%/g,'.')+'">'+heading+'</a></td>'));break;}else{results.push(void0);}}returnresults;});});}staticcategorizePromotedPageType(){varconditions,featuredTypes,pageType,type;featuredTypes={'articles':{'all':'Wikipedia:Featured articles','promoted':'Wikipedia:Featured articles promoted in YEAR'}};for(typeinfeaturedTypes){conditions=featuredTypes[type]['promoted']&&window.mw.config.get('wgPageName').replace(/_/g,' ').indexOf(featuredTypes[type]['promoted'].replace('YEAR',''))===0;if(conditions){pageType=featuredTypes[type];break;}}returnpageType;}staticescapeRegExp(str){returnstr.replace(/[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,'\\$&');}staticinit(){varpageType,parameters;if(!window.mw.config.get('wgPageName')){returnfalse;}pageType=CategorizePromoted.categorizePromotedPageType();if(!pageType){returnfalse;}// Fix the width of each columnwindow.mw.util.addCSS('.wikitable th:nth-child(1) { width: 25%; } .wikitable th:nth-child(2) { width: 15%; } .wikitable th:nth-child(3) { width: 30%; } .wikitable th:nth-child(4) { width: 30%; }');parameters={action:'query',prop:'revisions',rvdir:'older',rvlimit:1,rvprop:'content',titles:pageType['all'],format:'json'};return$.get(window.mw.config.get('wgScriptPath')+'/api.php',parameters,CategorizePromoted.categorizePromotedCallback);}};$(function(){returnCategorizePromoted.init();});}).call(this);