User:Sohom Datta/fastreview.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Sohom Datta/fastreview. |
// @ts-check
// Delay untill the toolbar loads
mw.hook( 'ext.pageTriage.toolbar.ready' ).add( function () {
mw.loader.using( [ 'mediawiki.api' ], function () {
if ( mw.storage.get( 'user-js-fastreview-temp-tk' ) ) {
mw.notify( 'Reviewed page!' );
mw.storage.remove( 'user-js-fastreview-temp-tk' );
}
document.addEventListener( 'keydown', function ( e ) {
if ( e.target !== document.body ) {
return;
}
if ( ( e.key === 'r' || e.key === 't' ) && mw.config.get( 'wgIsRedirect' ) ) {
new mw.Api( {
ajax: {
headers: {
'Api-User-Agent': 'User:Sohom_Datta/fastreview.js'
}
}
} ).postWithEditToken( {
action: 'pagetriageaction',
reviewed: 1,
// @ts-ignore
pageid: mw.config.get( 'wgRelevantArticleId' )
} ).then( function () {
mw.storage.set( 'user-js-fastreview-temp-tk', '1' );
if ( e.key === 'r' ) {
setTimeout( function () {
document.location.reload();
}, 1 );
} else {
// eslint-disable-next-line no-jquery/no-global-selector
$( '#mwe-pt-next .mwe-pt-tool-icon' ).trigger( 'click' );
}
} ).catch( function () {
mw.notify( 'Failed to review page' );
} );
}
if ( e.key === 'b' ) {
history.back();
}
if ( e.key === 'n' ) {
// We need a better API for this, but this hack works for now!
// eslint-disable-next-line no-jquery/no-global-selector
$( '#mwe-pt-next .mwe-pt-tool-icon' ).trigger( 'click' );
}
} );
} );
} );