MediaWiki:ClearSandbox/code.js

var content = window.clearSandboxContent || ''; var summary = window.clearSandboxSummary || 'Cleanup';

if ( wgPageName.indexOf("sandbox") >= 0 || wgPageName.indexOf("Sandbox") >= 0 ) { $('#WikiaMainContent .wikia-menu-button .WikiaMenuElement').append('Clear sandbox'); }

$('#clear-sandbox').click(function{   $.post(mw.util.wikiScript( 'api' ), { format: 'json', action: 'edit', title: wgPageName, text: content, minor: false, bot: true, summary: summary, token: mw.user.tokens.get("editToken") }, function( data ) { if (!data.error) { console.log('Sandbox cleaned successfully.'); } else { console.log('Failed:' + data.error.info); }   }); });