MediaWiki:Gadget-delete.js

// // This script tags pages using T:Delete // Which adds them to Flagged for deletion var pageid = mw.config.get( 'wgArticleId' ); var editSummary = 'Tagging page as using Deletion tagger'; var pageContent = ''; new mw.Api.get( { action: 'query',  prop: 'revisions|info',  rvprop: 'content',  pageids: pageid,  indexpageids: 1 } ).done( function ( pageResponse ) {  pageContent = pageResponse.query.pages[ pageid ].revisions[ 0 ][ '*' ]; } ); mw.util.addPortletLink( 'p-cactions',  '#',  'Delete',  'ca-mark-delete',  'Mark this page for deletion',  null,  null ); $( '#ca-mark-delete' ).click( function ( e ) { e.preventDefault;  var tagReason = prompt( 'Why do you want this page deleted?\n\n\tFailure to provide a reasonable answer will result in request being denied.', 'TEST!!!' );  if ( !mw.config.get( 'wgIsRedirect' ) ) {    pageContent = '\n' + pageContent;// put it on the top of the page  } else {    pageContent += '\n\n';// put it on the bottom of the page  }  new mw.Api.postWithToken( 'edit', { action: 'edit', pageid: pageid, text: pageContent, summary: editSummary } ).done( function ( tagged ) { if ( tagged.edit.result === 'Success' ) { alert( 'Page was tagged!' ); location.reload; } else { alert( 'Page was NOT tagged!' ); } } ); } ); //