Content deleted Content added
caps |
a whole bunch of cleanup based on draft no cat, warning: not tested, please let me know if stuff breaks |
||
(One intermediate revision by the same user not shown) | |||
Line 5:
//
// If forking this script, please note my contributions / give me credit
$(() => {
window.DraftReCat = DraftReCat;
DraftReCat.config = {
name: '[[User:DannyS712/Draft re cat|draft re cat]]',
version: 1.
debug: false
};
DraftReCat.run = function () {
if ( DraftReCat.config.debug ) {
console.log ( DraftReCat.summary );
var api = new mw.Api();
api.get( {
rvslots: 'main',
formatversion: 2
} ).done(
function ( response ) {
console.log( response );
var text = response.query.pages[0].revisions[0].slots.main.content;
api.postWithEditToken( {
text: newText,
summary: DraftReCat.summary
} ).done(
}
);
}
};▼
});
$( document ).ready( () => {
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) { [ 'mediawiki.util' ], function () { ▲ var link = mw.util.addPortletLink( 'p-cactions', '#', 'DRC', 'ca-drc', 'Draft re cats');
▲ $( link ).click( function ( event ) {
mw.loader.using( 'mediawiki.api', window.DraftReCat.run );
▲ event.preventDefault();
}
}▼
} );
▲}
▲ action: 'query',
▲ titles: mw.config.get( 'wgPageName' ),
▲ prop: 'revisions',
▲ rvprop: 'content',
▲ };
▲ text = text
▲ .replace( /\[\[:Category/gi, '\[\[Category' ); // Replace links with categorization
▲ action: 'edit',
▲ pageid: mw.config.get( 'wgArticleId' ),
▲ ).done( function() {
▲ ___location.reload();
▲ } );
▲ } );
▲}
|