跳转到内容

User:Wcam/copy diff link.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// From [[special:diff/62837483]], by User:AnYiLin
(() => {
	var query = value => {
		var m = location.search.substr(1).match(new RegExp(`(^|&)${value}=([^&]*)(&|$)`, 'i'));
		return m ? decodeURIComponent(m['2']) : false;
		
	};
	var diff = query('diff'), oldid = query('oldid');
	if (document.getElementById('p-cactions') && (diff || oldid)) {
		mw.util.addPortletLink('p-cactions', '#', wgUVS('当前差异链接', '當前差異網址'), 't-difflink', wgUVS('复制当前地址栏中的差异链接(维基语法)', '複製當前地址欄中的差異網址(維基語法)'));
		document.getElementById('t-difflink').addEventListener('click', () => {
			OO.ui.alert(
				new mw.widgets.CopyTextLayout({copyText: `[[Special:diff/${oldid}${diff?`/${diff}`:''}]]`}).$element
			)
		})
	}
})();