注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
mw.loader.using( ['mediawiki.util','mediawiki.widgets', 'oojs-ui-windows'], function () {
main();
function cdb( cid, href, title, t, a , b) {
var att = ""
if (a) {
att = a + '="' + b + '" '
}
return '<span class="cd-button-ooui cd-comment-button-ooui oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-labelElement oo-ui-buttonWidget cd-comment-button PQR-cd PQR-cd-' + cid + '"><a class="oo-ui-buttonElement-button" role="button" '+ att +'href="' + href + '" title="' + title + '" tabindex="0" rel="nofollow"><span class="oo-ui-iconElement-icon oo-ui-iconElement-noIcon"></span><span class="oo-ui-labelElement-label">' + t + '</span><span class="oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator"></span></a></span>'
}
function main() {
$('.cd-commentLayersContainer .cd-comment-overlay:not(.PQR-cd-ol-marker)').each(function () {
id = $(this).find('.oo-ui-icon-link').parent().attr("href");
if (id) {
user = id.slice(3).replace(/^(.*?)-?\d{4}-?\d{2}-?\d{2}T?\d{2}:?\d{2}:?\d{2}(\.\d{3}Z)?-.*$/g, '$1');
userpage = "/wiki/User:" + user;
talk = "/wiki/User_talk:" + user;
contribs = "/wiki/Special:Contribs/" + user;
$(this).find('.oo-ui-icon-link').parent().parent().before($(cdb('user', userpage, 'User:' + user, 'U')));
$(this).find('.oo-ui-icon-link').parent().parent().before($(cdb('talk', talk, 'User talk:' + user, 'T')));
$(this).find('.oo-ui-icon-link').parent().parent().before($(cdb('contribs', contribs, 'Special:Contribs/' + user, 'C')));
$(this).find('.oo-ui-icon-link').parent().parent().before($(cdb('ping', '#', 'ping', 'P', 'user', user)));
$(this).addClass('PQR-cd-ol-marker')
}
});
$('.PQR-cd-ping').click(function (e) {
e.preventDefault();
user = $(this).children('a').attr('user');
if (user.search('=')>-1) {
ping = '{{ping|1=' + user + '}}';
parg = '|50=' + user;
} else {
ping = '{{ping|' + user + '}}';
parg = '|' + user;
}
mw.loader.using('oojs-ui').then(function () {
var $ping = $('<div>');
$ping.append(new mw.widgets.CopyTextLayout({ title: 'ping', copyText: ping }).$element);
$ping.append(new mw.widgets.CopyTextLayout({ title: 'parg', copyText: parg }).$element);
OO.ui.alert($ping);
});
});
}
let iid;
setInterval(() => {
if ($('.cd-commentLayersContainer .cd-comment-overlay:not(.PQR-cd-ol-marker)').length !== 0) {
main();
}
}, 200);
});