User:Lopullinen/gadgets/metadata-videogame.js
< User:Lopullinen | gadgets
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
$(function () {
let pageTitle = mw.config.get('wgTitle'), namespaceNumber = mw.config.get('wgNamespaceNumber');
if (namespaceNumber % 2 == 1 || namespaceNumber < 0) { return; }
var api = new mw.Api();
const classList = [
{ category: '未评级电子游戏条目', color: '#bbb' },
{ category: '小作品级电子游戏条目', color: '#901' },
{ category: '初级电子游戏条目', color: '#b60' },
{ category: '丙级电子游戏条目', color: '#993' },
{ category: '乙级电子游戏条目', color: '#6b0' },
{ category: '优良级电子游戏条目', color: '#070' },
{ category: '典范级电子游戏条目', color: '#06c' },
{ category: '小列表级电子游戏条目', color: '#901' },
{ category: '列表级电子游戏条目', color: '#85f' },
{ category: '丙级列表级电子游戏条目', color: '#993' },
{ category: '乙级列表级电子游戏条目', color: '#6b0' },
{ category: '特色列表级电子游戏条目', color: '#06c' },
{ category: '分类级电子游戏条目', color: '#FFDB58' },
{ category: '消歧义级电子游戏条目', color: '#00FA9A' },
{ category: '草稿级电子游戏条目', color: '#E7B198' },
{ category: '文件级电子游戏条目', color: '#DDCCFF' },
{ category: '主题级电子游戏条目', color: '#DDB1BC' },
{ category: '专题级电子游戏条目', color: '#C0C090' },
{ category: '模板级电子游戏条目', color: '#FBCEB1' },
{ category: '不适用级电子游戏条目', color: '#bebebe' }
];
const importanceList = [
{ category: '未知重要度电子游戏条目', color: 'inherit' },
{ category: '低重要度电子游戏条目', color: '#ffddff' },
{ category: '中重要度电子游戏条目', color: '#ffbbff' },
{ category: '高重要度电子游戏条目', color: '#ff88ff' },
{ category: '极高重要度电子游戏条目', color: '#ff00ff' },
{ category: '不适用重要度电子游戏条目', color: '#f5f5f5' }
];
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('电子游戏条目', '');
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(subtitlePrefix);
return;
}
}
}
});
});