MediaWiki:Common.js:修订间差异
MediaWiki界面页面
更多操作
初始化 |
拦截退出按钮 |
||
| 第1行: | 第1行: | ||
( function () { | ( function () { | ||
'use strict'; | 'use strict'; | ||
var MAIN_SITE = 'https://www.dolshipmaker.vip'; | |||
var WIKI_BASE = 'https://wiki.dolshipmaker.vip'; | |||
function interceptLogout() { | |||
$( document ).on( 'click', 'a[href*="action=logout"], a[href*="Special:UserLogout"]', function ( e ) { | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
fetch( MAIN_SITE + '/api/auth/cookie-logout', { | |||
method: 'POST', | |||
credentials: 'include' | |||
} ).finally( function () { | |||
window.location.href = MAIN_SITE + '/login.html?redirect=' + encodeURIComponent( WIKI_BASE ); | |||
} ); | |||
} ); | |||
} | |||
} | } | ||
function interceptEditForAnon() { | |||
if ( mw.config.get( 'wgUserId' ) !== 0 ) return; | |||
$( document ).on( 'click', 'a[href*="action=edit"], a[href*="veaction=edit"]', function ( e ) { | |||
function | |||
$( 'a[href*="action=edit"], a[href*="veaction=edit"] | |||
e.preventDefault(); | e.preventDefault(); | ||
window.location.href = MAIN_SITE + '/login.html?redirect=' + encodeURIComponent( window.location.href ); | |||
window.location.href = | |||
} ); | } ); | ||
} | } | ||
mw.loader.using( 'mediawiki.util' ).done( function () { | mw.loader.using( 'mediawiki.util' ).done( function () { | ||
$( document ).ready( function () { | |||
$( document ).ready( | interceptLogout(); | ||
interceptEditForAnon(); | |||
} ); | |||
} ); | } ); | ||
}() ); | }() ); | ||
2026年4月14日 (二) 23:24的版本
( function () {
'use strict';
var MAIN_SITE = 'https://www.dolshipmaker.vip';
var WIKI_BASE = 'https://wiki.dolshipmaker.vip';
function interceptLogout() {
$( document ).on( 'click', 'a[href*="action=logout"], a[href*="Special:UserLogout"]', function ( e ) {
e.preventDefault();
e.stopPropagation();
fetch( MAIN_SITE + '/api/auth/cookie-logout', {
method: 'POST',
credentials: 'include'
} ).finally( function () {
window.location.href = MAIN_SITE + '/login.html?redirect=' + encodeURIComponent( WIKI_BASE );
} );
} );
}
function interceptEditForAnon() {
if ( mw.config.get( 'wgUserId' ) !== 0 ) return;
$( document ).on( 'click', 'a[href*="action=edit"], a[href*="veaction=edit"]', function ( e ) {
e.preventDefault();
window.location.href = MAIN_SITE + '/login.html?redirect=' + encodeURIComponent( window.location.href );
} );
}
mw.loader.using( 'mediawiki.util' ).done( function () {
$( document ).ready( function () {
interceptLogout();
interceptEditForAnon();
} );
} );
}() );