跳转到内容

User:魔琴/gadgets/TCP/tcp.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
//<nowiki>
mw.loader.using( 'mediawiki.util' , function () {
$('.mw-heading2 h2 a').each(function(){
	page = $(this).attr('href').replace(/^(https:\/\/zh\.(m\.)?wikipedia.org)?\/w(\/index\.php\?title=|iki\/)(.*?)(&.*)?$/g,'$4');
	try {
		page = decodeURI(page);
	} catch (e) { // catches a malformed URI
		console.error(e);
	}
	if (page.slice(0,5) !== 'User:') return;
	user = page.slice(5);
	html = `<sup style="user-select:none">&nbsp;[&nbsp;<a href="/wiki/User_talk:${user}">T</a>&nbsp;<a href="/wiki/Special:Contribs/${user}">C</a>&nbsp;<a class="TCP-ping" user="${user}" href="javascript:void(0)">P</a>&nbsp;]&nbsp;</sup>`
	$(this).after(html);
});

$('.TCP-ping').click(function(e) {
	e.preventDefault();
	user = $(this).attr('user');
	ping = '{{ping|' + user + '}}';
	mw.loader.using('oojs-ui').then(function () {
		OO.ui.alert(
			new mw.widgets.CopyTextLayout({ title: 'ping', copyText: ping }).$element
		);
	});
});
});
//</nowiki>