diff --git a/README.md b/README.md index 461ebb9..fc93979 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ Your contributions are welcome! Please add feature requests and bug reports as n If you'd like to contribute directly to the code, that's great too! In order to maintain great code quality, please submit significant changes using pull requests so that a consistent code style can be maintained throughout the project. +**Protip for developers**: Set `AFCH.consts.mockItUp = true;` using your browser console and instead of making API requests which modify wiki content, the script will log what it *would have done* instead. + ### Version history * 0.2 Egalitarian Elephant diff --git a/src/modules/core.js b/src/modules/core.js index 239dc92..493a337 100644 --- a/src/modules/core.js +++ b/src/modules/core.js @@ -41,6 +41,9 @@ // Add more constants $.extend( AFCH.consts, { + // If true, the script will NOT modify actual wiki content and + // will instead mock all such API requests (success assumed) + mockItUp: false, // Edit token used in api requests editToken: mw.user.tokens.get( 'editToken' ), // Full page name, "Wikipedia talk:Articles for creation/sandbox" @@ -363,6 +366,12 @@ request[options.mode] = options.contents; } + if ( AFCH.consts.mockItUp ) { + AFCH.log( request ); + deferred.resolve(); + return deferred; + } + AFCH.api.post( request ) .done( function ( data ) { if ( data && data.edit && data.edit.result && data.edit.result === 'Success' ) { @@ -422,6 +431,12 @@ token: AFCH.consts.editToken // Move token === edit token }, additionalParameters ); + if ( AFCH.consts.mockItUp ) { + AFCH.log( request ); + deferred.resolve( { to: newTitle } ); + return deferred; + } + AFCH.api.post( request ) .done( function ( data ) { if ( data && data.move ) {