User:Jreppch/test.js

var request = require('request').defaults({jar: true}), url = "https://en.wikipedia.org/wiki/User:Jreppch/Pages_I_have_read";

function getCsrfToken { var params_2 = { action: "query", meta: "tokens", format: "json" };

request.get({ url: url, qs: params_2 }, function(error, res, body) {       if (error) {            return;        }        var data = JSON.parse(body);        editRequest(data.query.tokens.csrftoken);    }); }

// Step 4: POST request to edit a page function editRequest(csrf_token) { var params_3 = { action: "edit", title: "Project:Sandbox", appendtext: "test edit", token: csrf_token, format: "json" };

request.post({ url: url, form: params_3 }, function (error, res, body) {       if (error) {            return;        }        console.log(body);    }); }

getCsrfToken;