User:Jon Harald Søby/common.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/*mw.loader.using( [ 'mediawiki.api', 'mediawiki.util' ] ).then( function() {
var api = new mw.Api(),
foreignApi = new mw.ForeignApi( 'https://ka.wikisource.org/w/api.php' ),
currentPage = mw.config.get( 'wgPageName' );
if (
mw.config.get( 'wgArticleId' ) === 0
) {
return;
}
function newRandom() {
window.location.href = mw.util.getUrl( 'Special:RandomInCategory/Georgian' );
}
if ( !( [ 0, 104, 106 ].includes( mw.config.get( 'wgNamespaceNumber' ) ) ) ) {
newRandom();
return;
}
var foreignApiQuery = {
action: 'query',
format: 'json',
formatversion: 2,
prop: 'info',
titles: currentPage
};
var deleteQuery = {
action: 'delete',
format: 'json',
formatversion: 2,
title: currentPage,
reason: 'Moved to [[:ka:' + currentPage + ']]'
};
foreignApi.get( foreignApiQuery ).then( function( data ) {
var pagedata = data.query.pages[ 0 ];
if ( pagedata.missing ) {
newRandom();
return;
}
api.postWithEditToken( deleteQuery ).then( function( data ) {
newRandom();
return;
});
});
});
*/