Thành viên:NguoiDungKhongDinhDanh/Antispoof.js
Chú ý: Sau khi lưu thay đổi trang, bạn phải xóa bộ nhớ đệm của trình duyệt để nhìn thấy các thay đổi. Google Chrome, Firefox, Internet Explorer và Safari: Giữ phím ⇧ Shift và nhấn nút Reload/Tải lại trên thanh công cụ của trình duyệt. Để biết chi tiết và hướng dẫn cho các trình duyệt khác, xem Trợ giúp:Xóa bộ nhớ đệm.
/** <nowiki>
* Công cụ hỗ trợ kiểm thử tên người dùng mới.
* Chỉ hoạt động ở [[WP:DTND]].
**/
$(function() {
// Chỉ hoạt động ở [[WP:DTND]].
if (mw.config.get('wgArticleId') !== 132322) {
return;
}
$('.dtnd-antispoof-newname > a:first-child').each(function() {
$(this).after(
' <span class="dtnd-antispoof-link" style="color: #000; font-weight: bold;">' +
'<span style="margin: 0 0.1em;">[</span>' +
'<a ' +
'dtnd-antispoof-value="' + $(this).text() + '" ' +
'style="color: #8b0000; font-size: small;"' +
'>' +
'kiểm thử' +
'</a>' +
'<span style="margin: 0 0.1em;">]</span>' +
'</span>'
);
});
$('#content').on('click', '.dtnd-antispoof-link > a', function(e) {
e.preventDefault();
(new mw.Api()).get({
action: 'antispoof',
username: $(this).attr('dtnd-antispoof-value')
}).done(function({antispoof: response}) {
if (response.result == 'pass') {
mw.notify(
'Tên người dùng không giống hay trùng với bất kỳ tên nào ' +
'đã được đăng ký.',
{
type: 'success',
title: 'Không tìm thấy!'
}
);
} else {
mw.notify(
`Tên người dùng giống hoặc trùng với ít nhất một tên ' +
'đã được đăng ký: ${response.users.join(', ')}.`,
{
type: 'error',
title: 'Có xung đột!'
}
);
navigator.clipboard.writeText(
'{{an5|rename|w|' + response.users.join('|') + '}}'
);
}
});
});
});
// </nowiki>