function closeReq(info){ console.log("clicked close request button") var api = new mw.Api(); api.postWithToken("csrf", {action: 'edit
function closeReq(info){
console.log("clicked close request button")
var api = new mw.Api();
api.postWithToken("csrf", {action: 'edit', title: info.title, appendtext: info.text, summary: info.summary, section: 2} ).done(function( data ) {
alert( 'Page edited!' );
} ).fail( function(code, data) {
console.log( api.getErrorMessage( data ).text());
} );
}
function doSomethingWithText( wikitext ) {
console.log(wikitext);
}
function doSomethingInCaseOfError () {console.log( 'err' );}
console.log("rmMaster init")
$('.mw-heading').each( function(index){ //Look for each section in the page
var $heading = $(this).find('span.mw-headline') //Fetch for its text content
if($heading.text().trim().includes("Requested move")){ //If it contains the words Requested move, which supposedly all RMdiscs would then continue
console.log("found rmdisc")
$(this).append("<button>Close Request</button>") //Append a test Button
}
else{
console.log($heading.text().trim()) //Otherwise print the content of the heading for debudding
}
}
);
$('button').click(function(){
var user = 'User:' + mw.config.get( 'wgUserName' );
closeReq({title: 'Wikipedia:Sandbox',text: '{{subst:RM top' + '|<b>Moved</b>}}',summary: '[[' + user + ']] closed request using rmCloser'});
$.getJSON(mw.util.wikiScript('api'),
{format: 'json', action: 'query', prop: 'revisions', rvprop: 'content', rvlimit: 1, titles: 'Wikipedia:Sandbox'}).then(function ( data ) {
var page, wikitext;
try {
for ( page in data.query.pages ) {
wikitext = data.query.pages[page].revisions[0]['*'];
doSomethingWithText( wikitext );
}
} catch ( e ) {
doSomethingInCaseOfError();
}
}).catch( doSomethingInCaseOfError );
})
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.