In PageTriage, we can remove a lot of custom code that uses $.ajax() (15 matches in 8 files) and make use of API functions provided by the mw JavaScript object (mw.Api().saveOption(), mw.user.options.get(), and mw.Api().postWithToken() , etc. For example, the apiSetFilterParams(), saveFilterParams(), setToolbarPreference(), finishSetToolbarPreference() contain code that request a token, then make a request. For example saveFilterParams() has:
if ( this.optionsToken ) { this.apiSetFilterParams(); } else { tokenRequest = { action: 'tokens', type: 'options', format: 'json' }; $.ajax( { type: 'get', url: mw.util.wikiScript( 'api' ), data: tokenRequest, dataType: 'json', success: function ( data ) { try { that.optionsToken = data.tokens.optionstoken; } catch ( e ) { throw new Error( 'Could not get token (requires MediaWiki 1.20).' ); } that.apiSetFilterParams(); } } ); }
which can be simplified with mw.Api().postWithToken().
There are other sections of code, for example submit() in ext.pageTriage.delete.js which could be rewritten in a more concise way to use mw.Api().postWithToken().