Skip to content

Instantly share code, notes, and snippets.

@jdlrobson
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdlrobson/eca5ef61261ffd39cf9f to your computer and use it in GitHub Desktop.
Save jdlrobson/eca5ef61261ffd39cf9f to your computer and use it in GitHub Desktop.
Populate a list of categories on MobileFrontend - run this in your console
function makeStockContent( titles, content ) {
var M = mw.mobileFrontend;
mw.loader.using( 'mobile.editor.api').done( function() {
var EditorApi = M.require( 'modules/editor/EditorApi' );
titles.forEach( function( title ) {
var api = new EditorApi( {
title: title,
isNewPage: true
} );
api.setContent( content );
api.save();
} );
} );
}
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var titles = [];
for(var i=0; i < possible.length; i++ ) {
titles.push(possible[i] + ' category test' );
}
makeStockContent( titles, '[[Category:Test]]' );
makeStockContent( [ 'Category:Test' ], 'Testing.' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment