User:Tommyang/Script/CurRevisionId.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/*
a user script that displays various URLs of current page next to page title
Original version by User:Kegns [https://zh.wikipedia.org/?oldid=30618120]
Click to select the URL for copying and to switch between article URL (?curid) and current revision URL (?oldid)
*/
if (mw.config.get('wgCurRevisionId') != 0) {
var i = 1;
var articleURL = `https:${mw.config.get('wgServer')}/?curid=${mw.config.get('wgArticleId')}`;
var revisionURL = `https:${mw.config.get('wgServer')}/?oldid=${mw.config.get('wgCurRevisionId')}`;
$('h1#firstHeading span[dir=auto]').text(mw.config.get('wgPageName'));
$('h1#firstHeading').append($("<input />").attr({
"id": "pageurls",
"type": "url",
"value": articleURL,
"size": articleURL.length,
"readonly": "true",
}).css({
"background-color": "transparent",
"margin-left": "1em",
"border-style": "none",
"color": "rgba(0, 0, 0, 0.6)",
}));
$('#pageurls').mousedown(function () {
i = (i + 1) % 2;
switch (i) {
case 0:
$('#pageurls').attr({
"value": articleURL,
"size": articleURL.length
});
break;
case 1:
$('#pageurls').attr({
"value": revisionURL,
"size": revisionURL.length
});
break;
}
}
).mouseup(function () {
this.select();
});
}