Node.prototype.gel = function (id) { return this.getElementById(id); } Node.prototype.gcn = function (classname) { return this.getElementsByClassName(classname); } function dgel(id) { return document.getElementById(id); } function dgcn(classname) { return document.getElementsByClassName(classname); } /** * Asynchronous function. Promises the text content of url. Automatically adds/removes from the loading counter. * @param {string} url URL to request. Note that unless cross-domain is specifically permitted, this URL must come from the same domain as this file. */ async function ajax(url) { //must be called from an async function! use 'await', e.g. "var result = await ajax('https://google.com');" return new Promise(resolve => { var pageGetter = new XMLHttpRequest; pageGetter.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { resolve(this.responseText); } else if (this.readyState == 4) { resolve('Error: Expecting HTTP 200, got HTTP ' + this.status) } } pageGetter.open('GET', url, true) pageGetter.send(); }); } async function cont() { url = dgel('instance-input').value; j = await ajax('/internal/auth_a?url=' + url) console.log(j) }