User:Lopullinen/sandbox.js

$(function {  const pageTitle = mw.config.get('wgTitle'), namespaceNumber = mw.config.get('wgNamespaceNumber');

if (namespaceNumber % 2 == 1 || namespaceNumber < 0) { return; }

let api = new mw.Api;

const classList = [ { category: 'Unassessed_video_game_articles', color: 'inherit' }, { category: 'Stub-Class_video_game_articles', color: '#901' }, { category: 'Start-Class_video_game_articles', color: '#b60' }, { category: 'C-Class_video_game_articles', color: '#993' }, { category: 'B-Class_video_game_articles', color: '#6b0' }, { category: 'GA-Class_video_game_articles', color: '#070' }, { category: 'FA-Class_video_game_articles', color: '#06c' }, { category: 'List-Class_video_game_articles', color: '#85f' }, { category: 'FL-Class_video_game_articles', color: '#06c' },

{ category: 'Category-Class_video_game_articles', color: '#FFDB58' }, { category: 'Disambig-Class_video_game_articles', color: '#00FA9A' }, { category: 'Draft-Class_video_game_articles', color: '#E7B198' }, { category: 'File-Class_video_game_articles', color: '#DDCCFF' }, { category: 'Portal-Class_video_game_articles', color: '#DDB1BC' }, { category: 'Project-Class_video_game_articles', color: '#C0C090' }, { category: 'Template-Class_video_game_articles', color: '#FBCEB1' }, { category: 'NA-Class_video_game_articles', color: '#inherit' }

];

const importanceList = [ { category: 'Unknown-importance_video_game_articles', color: 'inherit' }, { category: 'Low-importance_video_game_articles', color: 'inherit' }, { category: 'Mid-importance_video_game_articles', color: 'inherit' }, { category: 'High-importance_video_game_articles', color: 'inherit' }, { category: 'Top-importance_video_game_articles', color: 'inherit' }, { category: 'NA-importance_video_game_articles', color: 'inherit' } ];

api.getCategories(   new mw.Title(pageTitle, namespaceNumber).getTalkPage.getPrefixedText  ).done(function (data) {    let subtitlePrefix = "";

for (let v = 0; v < data.length; v++) { for (let w = 0; w < classList.length; w++) { if (data[v].title == classList[w].category) { $('h1#firstHeading').css('color', classList[w].color); subtitlePrefix = classList[w].category.replace('_video_game_articles', ' '); break; }     }    }    if (!subtitlePrefix) { return; } for (let v = 0; v < data.length; v++) { for (let w = 0; w < importanceList.length; w++) { if (data[v].title == importanceList[w].category) { subtitlePrefix += importanceList[w].category; subtitlePrefix += " － " + $('div#siteSub').text; $('div#siteSub').text("A " + subtitlePrefix.replace(/_/g, " ").replace("articles", "article")); return; }     }    }

});

});