사용자:Wotheina/diff-permalink.js
참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다. 구글 크롬, 파이어폭스, 마이크로소프트 엣지, 사파리: ⇧ Shift 키를 누른 채 "새로 고침" 버튼을 클릭하십시오. 더 자세한 정보를 보려면 위키백과:캐시 무시하기 항목을 참고하십시오.
// <nowiki>
// based on [[User:Enterprisey/diff-permalink.js]] 2022-06-12
// rev 2022-09-01
$.when( $.ready, mw.loader.using( [ "mediawiki.util" ] ) ).then( function () {
var suffix = mw.config.get( "wgDiffNewId" );
var page;
if( suffix ) {
if( document.getElementsByClassName( "diff-multi" ).length ||
mw.config.get("wgCanonicalSpecialPageName") === "ComparePages" ) {
suffix = mw.config.get( "wgDiffOldId" ) + "/" + suffix;
}
page = "[[Special:Diff/" + suffix + "]]";
} else {
var oldidMatch = mw.util.getParamValue( "oldid" );
if( oldidMatch ) {
page = "[[Special:Permalink/" + oldidMatch + "]]";
} else return; // nothing to do here
}
var permalinkEl = $( "<div>" ).append(
"Permalink to this " + ( suffix ? "diff" : "oldid" ) + ": ",
$( "<input>" )
.attr( { "id": "diff-permalink-link" } )
.attr( "size", page.length )
.val( page ),
$( "<button>" )
.text( "Copy" )
.css( { "cursor": "pointer", "margin-left": "0.5em" } )
.click( function () {
document.getElementById( "diff-permalink-link" ).select();
document.execCommand( "copy" );
} ) );
if( suffix ) {
$( "#bodyContent" ).prepend( permalinkEl );
} else {
$( "#contentSub" ).after( permalinkEl );
}
// $( "#diff-permalink-link" ).attr( "size", page.length ); // resize to diff length
} );
// </nowiki>