2023年政策修订增补工作正在进行中,欢迎参与!
  • Moegirl.ICU:萌娘百科流亡社群 581077156(QQ),欢迎对萌娘百科运营感到失望的编辑者加入
  • Moegirl.ICU:账号认领正在试运行,有意者请参照账号认领流程

User:W3jc/js/UserLevel.js

萌娘百科,万物皆可萌的百科全书!转载请标注来源页面的网页链接,并声明引自萌娘百科。内容不可商用。
< User:W3jc‎ | js
跳转到导航 跳转到搜索

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox/Safari:按住“Shift”的同时单击“刷新”,或按“Ctrl-F5”或“Ctrl-R”(Mac为“⌘-R”)
  • Google Chrome:按“Ctrl-Shift-R”(Mac为“⌘-Shift-R”)
  • Internet Explorer:按住“Ctrl”的同时单击“刷新”,或按“Ctrl-F5”
  • Opera:在“工具→首选项”中清除缓存
如果您已登录但该页面出现未登录状态,请尝试在地址栏的地址最后添加代码?_=1来访问最新页面。
添加代码后的本页地址如下:-{R|https://moegirl.icu/User:W3jc/js/UserLevel.js?_=1}-
//用户组等级条
var userGroups = mw.config.get("wgUserGroups");
var userEditCount = mw.config.get("wgUserEditCount");
var userEditDays = 0;
const queryUserContribs = {
	"action": "query",
	"format": "json",
	"list": "usercontribs",
	"uclimit": "1",
	"ucuser": mw.config.get("wgUserName"),
	"ucdir": "newer",
	"ucprop": "timestamp"
};
const api = new mw.Api();
api.get(queryUserContribs).done(function (data) {
	userEditDays = moment().diff(moment(data.query.usercontribs[0].timestamp), 'days');
	updateData();
});
var $userLevel = $("<li id='pt-userlevel' style='display:flex;flex-direction:row;align-items:center;margin-top:0.6em'></li>");
var $editDaysBar = $("<progress id='editdaysbar' style='width:45px' value='0' max='0' title='编辑天数:0/0'></progress>");
var $editCountBar = $("<progress id='editcountbar' style='width:45px' value='0' max='0' title='编辑次数:0/0'></progress>");
var $currentLevel = $("<a id='currentLevel' href='/Special:创建账户' title='当前用户组'>匿</a>");
var $nextLevel = $("<a id='nextLevel' href='/MGP:用户' title='更高用户组'>用</a>");
var $editBars = $("<div style='display:flex;flex-direction:column'></div>");
$userLevel.append($currentLevel, $editBars.append($editDaysBar, $editCountBar), $nextLevel);
$("#pt-userpage").after($userLevel);
function updateData() {
	if ((userGroups.indexOf("special-contributor") != -1)) {//特贡
		$currentLevel.text("特");
		$currentLevel.attr({"href":"/MGP:特殊贡献者"});
		$nextLevel.text("-");
		$nextLevel.attr({"href":"#"});
		$editDaysBar.attr({"value":userEditDays, "style":"accent-color:#A5E4A5;width:45px", "title":"编辑天数:"+userEditDays+"/-"});
		$editCountBar.attr({"value":userEditCount, "style":"accent-color:#A5E4A5;width:45px", "title":"编辑次数:"+userEditCount+"/-"});
	} else if ((userGroups.indexOf("sysop") != -1) || (userGroups.indexOf("patroller") != -1)) {//管维
		$currentLevel.text("维");
		$currentLevel.attr({"href":"/MGP:维护人员的基本义务"});
		$nextLevel.text("特");
		$nextLevel.attr({"href":"/MGP:特殊贡献者"});
		$editDaysBar.attr({"value":userEditDays, "style":"accent-color:#C0ECC0;width:45px", "title":"编辑天数:"+userEditDays+"/-"});
		$editCountBar.attr({"value":userEditCount, "style":"accent-color:#C0ECC0;width:45px", "title":"编辑次数:"+userEditCount+"/-"});
	} else if (userGroups.indexOf("goodeditor") != -1 ) {//优编
		$currentLevel.text("优");
		$currentLevel.attr({"href":"/MGP:优质编辑者"});
		$nextLevel.text("维");
		$nextLevel.attr({"href":"/MGP:维护人员的基本义务"});
		$editDaysBar.attr({"value":userEditDays, "style":"accent-color:#E6F6E6;width:45px", "title":"编辑天数:"+userEditDays+"/-"});
		$editCountBar.attr({"value":userEditCount, "style":"accent-color:#E6F6E6;width:45px", "title":"编辑次数:"+userEditCount+"/-"});
	} else if(userGroups.indexOf("extendedconfirmed") != -1) {//延确
		$currentLevel.text("延");
		$currentLevel.attr({"href":"/MGP:延伸确认用户"});
		$nextLevel.text("优");
		$nextLevel.attr({"href":"/MGP:优质编辑者"});
		$editDaysBar.attr({"value":userEditDays, "style":"accent-color:crimson;width:45px", "title":"编辑天数:"+userEditDays+"/-"});
		$editCountBar.attr({"value":userEditCount, "style":"accent-color:royalblue;width:45px", "title":"编辑次数:"+userEditCount+"/-"});
	} else if (userGroups.indexOf("autoconfirmed") != -1){//自确
		$currentLevel.text("自");
		$currentLevel.attr({"href":"/MGP:自动确认用户"});
		$nextLevel.text("延");
		$nextLevel.attr({"href":"/MGP:延伸确认用户"});
		$editDaysBar.attr({"value":userEditDays, "style":"accent-color:crimson;width:45px", "max":"90", "title":"编辑天数:"+userEditDays+"/90"});
		$editCountBar.attr({"value":userEditCount, "style":"accent-color:royalblue;width:45px", "max":"500", "title":"编辑次数:"+userEditCount+"/500"});
	} else if (userGroups.indexOf("user") != -1){//用户
		$currentLevel.text("用");
		$currentLevel.attr({"href":"/MGP:用户"});
		$nextLevel.text("自");
		$nextLevel.attr({"href":"/MGP:自动确认用户"});
		$editDaysBar.attr({"value":userEditDays, "style":"accent-color:crimson;width:45px", "max":"3", "title":"编辑天数:"+userEditDays+"/3"});
		$editCountBar.attr({"value":userEditCount, "style":"accent-color:royalblue;width:45px", "max":"10", "title":"编辑次数:"+userEditCount+"/10"});
	}
}