User:Cookai1205/js/Gadget-ComparePages.js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/* 對比草稿條目差異
縫合怪,本人完全不懂JS
*/
mw.loader.using( 'ext.gadget.HanAssist' ).then( ( require ) => {
const { batchConv } = require( 'ext.gadget.HanAssist' );
mw.messages.set( batchConv( {
'comparepages': { hans: '对比页面', hant: '比較頁面' },
'comparepagestitle': { hans: '对比草稿页与主页面', hant: '比較草稿頁與主頁面' },
} ) );
var title = mw.config.get( 'wgPageName' );
var url = mw.config.get( 'wgPageName' );
var urlm = mw.config.get( 'wgPageName' );
if ( mw.config.get( 'wgNamespaceNumber' ) == 118 ) {
if ( title.substring(title.length - 5) === '/temp' ) {
url = new mw.Uri('https://zh.wikipedia.org//wiki/Special:ComparePages')
.extend({
page1: title.substring(0, title.length - 5),
page2: title,
rev2: mw.config.get( 'wgRevisionId' )
});
urlm = new mw.Uri('https://zhwiki.oracleblog.org/wiki/Special:ComparePages')
.extend({
page1: title.substring(0, title.length - 5),
page2: title,
rev2: mw.config.get( 'wgRevisionId' )
});
} else {
url = new mw.Uri('https://zh.wikipedia.org//wiki/Special:ComparePages')
.extend({
page1: title.substring(6),
page2: title,
rev2: mw.config.get( 'wgRevisionId' )
});
urlm = new mw.Uri('https://zhwiki.oracleblog.org//wiki/Special:ComparePages')
.extend({
page1: title.substring(6),
page2: title,
rev2: mw.config.get( 'wgRevisionId' )
});
}
if ( ( mw.config.get( 'wgMFAmc' ) == true ) && ( $( '#p-tb' ).length != 0 ) ) {
$( '#p-tb' ).append( '<li class="mw-list-item mw-list-item-js toggle-list-item" id="t-cookaicmppage" data-minerva-portlet="true"><a class="toggle-list-item__anchor" href="' + urlm.toString() + '" data-mw="interface"><span class="minerva-icon minerva-icon--comparepages"></span><span class="toggle-list-item__label">' + mw.msg( 'comparepages' ) + '</span></a></li>' );
}
else {
addPortletLink(
'p-tb',
url.toString(),
mw.msg( 'comparepages' ),
'p-comparepages',
mw.msg( 'comparepagestitle' )
);
}
}
} );