跳转到内容

User:Shizhao/origintitle.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/*
用来显示页面的原始标题,显示在上方标签页左侧。
Author: [[User:Shizhao]], 2021
*/
if (mw.config.get('wgPageContentLanguage') != 'zh' && typeof wgULS !== 'undefined') {
	var title = mw.config.get('wgTitle');
	const portletLink = mw.util.addPortletLink(
		'p-associated-pages',
		{
			href: '',
			text: wgULS('原始标题', '原始標題'),
			id: 't-origintitle',
			tooltip: wgULS('语言变体环境下获取页面的原始标题', '語言變體環境下獲取頁面的原始標題'),
			accesskey: 'o',
			nextnode: '#ca-talk'
		}
	);
	$(portletLink).click(function(e) {
		e.preventDefault();
		mw.loader.using('oojs-ui').then(function () {
			OO.ui.alert(
				new mw.widgets.CopyTextLayout({ title: wgULS('本页的原始标题是:', '本頁的原始标题是:'), copyText: title }).$element
			);
		})
	});
}