注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
?_=1
来访问最新页面。https://zh.moegirl.org.cn/User:%E5%95%86%E7%81%AB/templeStatistics.js?_=1
/*
*名称:VC殿堂曲统计器
*作者:商火
*功能描述:计算每个VC歌姬已有的殿堂曲数
*版本:Beta 1.2
*安装方法:在个人js页添加代码 mw.loader.load('/index.php?title=User:商火/templeStatistics.js&action=raw&ctype=text/javascript');
*/
$('#n-recentchanges').after('<li><a id="templesofsingers" href="javascript:void(0);" onclick="templesOfSingers()">殿堂曲统计</a></li><li><a id="TempleSong" data-subpages="Vocaloid中文殿堂曲/2012年投稿|Vocaloid中文殿堂曲/2013年投稿|Vocaloid中文殿堂曲/2014年投稿|Vocaloid中文殿堂曲/2015年投稿|Vocaloid中文殿堂曲/2016年投稿|Vocaloid中文殿堂曲/2017年投稿|Vocaloid中文殿堂曲/2018年投稿|Vocaloid中文殿堂曲/梗曲相关" data-pattern="UP" href = "/Vocaloid中文殿堂曲">--首殿堂</a></li>');
(function(){
var promises=[], count=0, lastCount = 0, lastTime = 0;
$.each(["2012年投稿", "2013年投稿", "2014年投稿", "2015年投稿", "2016年投稿", "2017年投稿", "2018年投稿", "梗曲相关"],function(i,v){
promises.push($.get("/api.php",{format:"json",formatversion:2, action:"parse", page:"Vocaloid中文殿堂曲/" + v,prop:"wikitext"}).then(function(data){
count += data.parse.wikitext.match(RegExp($("#TempleSong").data("pattern"),"g")).length;
}));
});
promises.push($.get("/api.php", {format:"json", action:"parse", page:"Template:SubpageStringCounter/Vocaloid中文殿堂曲/default", prop:"wikitext"}).then(function(data){
lastObj = JSON.parse(data.parse.wikitext['*']);
}));
$.when.apply($,promises).then(function(){
$("#TempleSong").text(count - 174 + "首殿堂");/*
if (lastObj.counter !== count && mw.config.get('wgUserGroups').indexOf('autoconfirmed') !== -1){
lastObj.counter = count;
lastTime = lastObj.date;
lastObj.date = new Date().getTime();
lastObj.update_reason = 'data_expired (old date: \"' + lastTime + '\", new date: \"' + lastObj.date + '\")';
$.get('/api.php', {"action": "query", "meta": "tokens"}).then(function(data){
$.post('/api.php', {
action: 'edit',
format: 'json',
text: JSON.stringify(lastObj),
summary: 'Auto update reason: "data_expired" for page [[Vocaloid中文殿堂曲]]',
minor: true,
watchlist: 'nochange',
title: 'Template:SubpageStringCounter/Vocaloid中文殿堂曲/default',
tags: 'widgetSubpageStringCounter',
token: data.query.tokens.csrftoken.replace("+\\", "%2B%5C%5C")
}, function(){alert("success")});
});
}*/
});
})();
$('#footer').after('<div class="templeCounter" id="black_back" onclick="closeTemple()" style="display: none; position: fixed; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.6; opacity:.60; filter: alpha(opacity=60);"></div><div id="light_box" class="templeCounter" style="display: none; position: fixed; top: 25%; left: 25%; width: 50%; height: 30%; padding: 16px; border: 1px solid rgb(0, 0, 0); background-color: white; z-index:1002; overflow: auto;"><p>注意:以下数据只包括Bilibili投稿的中文殿堂曲;同时包括传说曲。</p><ul><li>洛天依:<span class="singer"></span>首</li><li>言和:<span class="singer"></span>首</li><li>心华:<span class="singer"></span>首</li><li>乐正绫:<span class="singer"></span>首</li><li>星尘:<span class="singer"></span>首</li><li>乐正龙牙:<span class="singer"></span>首</li><li>初音未来:<span class="singer"></span>首</li></div>');
function templesOfSingers() {
$('#templesofsingers').attr("onclick", "").text("刷新中...");
singer = new Array(0, 2, 3, 2, 0, -1, -2);//矫正值:洛、言、心、绫、尘、龙、初
var promises1 = [], greytexts = [];
time=setInterval("showResult()", 100);
$.each(["2012年投稿", "2013年投稿", "2014年投稿", "2015年投稿", "2016年投稿", "2017年投稿", "2018年投稿", "梗曲相关"], function (i, v) {
promises1.push($.get("/api.php", { format: "json", action: "parse", page: "Vocaloid中文殿堂曲/" + v, prop: "wikitext" }).then(function (data) {
var wikitext = data.parse.wikitext['*'];
var start = wikitext.indexOf("\u65b0}}");
var end = wikitext.lastIndexOf("/*");
if (end == -1) end = wikitext.length;
for (var point = start; point < end; point++) {
if (wikitext.charAt(point) == '#') {
switch (wikitext.substr(point + 1, 6).toUpperCase()) {
case "66CCFF": {
singer[0]++;
break;
}
case "00FFCC": {
singer[1]++;
break;
}
case "EE82EE": {
singer[2]++;
break;
}
case "EE0000": {
singer[3]++;
break;
}
case "9999FF": {
singer[4]++;
break;
}
case "006666": {
singer[5]++;
break;
}
case "39C5BB": {
singer[6]++;
break;
}
case "777777": {
for (var point1 = point + 6; wikitext.charAt(point1) != '['; point1++);
for (var point2 = point1 + 2; wikitext.charAt(point2) != '|' && wikitext.charAt(point2) != ']' && wikitext.charAt(point2) != '#'; point2++);
greytexts.push(wikitext.substring(point1 + 2, point2));
}
}
}
}
}));
});
$.when.apply($, promises1).then(function (){
$.each(greytexts, function (j, greytext) {
$.get("/api.php", { action: "parse", page: greytext, format: "json", prop: "categories" }).then (function (data) {
for (var i in data.parse.categories) {
switch (data.parse.categories[i]['*']) {
case "\u6d1b\u5929\u4f9d\u6b4c\u66f2":
singer[0]++;
break;
case "\u8a00\u548c\u6b4c\u66f2":
singer[1]++;
break;
case "\u5fc3\u534e\u6b4c\u66f2":
singer[2]++;
break;
case "\u4e50\u6b63\u7eeb\u6b4c\u66f2":
singer[3]++;
break;
case "\u661f\u5c18\u6b4c\u66f2":
singer[4]++;
break;
case "\u4e50\u6b63\u9f99\u7259\u6b4c\u66f2":
singer[5]++;
break;
case "\u521d\u97f3\u672a\u6765\u6b4c\u66f2":
singer[6]++;
break;
}
}
});
});
setTimeout("clearInterval(time)", 30000);
$('#templesofsingers').attr("onclick", "templesOfSingers()").text("更新统计结果");
});
}
function showResult (){
$('.templeCounter').css("display", "block");
$(".singer").text(function(index, old){
return singer[index];
});
}
function closeTemple (){
$('.templeCounter').css("display", "none");
clearInterval(time);
}