User:Sigilbaram/common.js

var apitest = function(section) { var api = new mw.Api; var promise = api.get({       action: 'query',        pageids: mw.config.get('wgArticleId'),        prop: 'revisions',        rvprop: 'content'    }).done(function (data) {        var original_text = data.query.pages[mw.config.get('wgArticleId')].revisions[0]['*']        var new_text = original_text + '\n===' + section + '==='        var token = api.getToken('edit')        api.postWithToken('edit', { action: 'edit', pageid: mw.config.get('wgArticleId'), summary: 'Adding section ' + section, text: new_text }).done(function (data) { console.log('Put done: ' + JSON.stringify(data)) location.reload }).fail(function (data) { console.log('Put failed: ' + JSON.stringify(data)) })   }).fail(function (data) {        console.log(JSON.stringify(data))    }); }