function newRedirect () { chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => { let currentUrl = tabs[0].url; const url = `${config.shlinkUrl}/rest/v3/short-urls`; let sendData = { "longUrl": currentUrl, "tags": ["Added by BOTv1"] }; const request = new XMLHttpRequest(); request.open('POST', url); request.setRequestHeader('accept', 'application/json'); request.setRequestHeader('X-Api-Key', `${config.shlinkApiKey}`); request.setRequestHeader('Content-type', 'application/json'); request.send(JSON.stringify(sendData)); request.onload = (e) => { var shortUrlOut = document.getElementById("output-shortUrl") var responseData = JSON.parse(request.response); shortUrlOut.value = `${config.shlinkOutUrl}/${responseData.shortCode}`; shlinkAppBtnRdUrl = `${config.shlinkAppUrl}/short-code/${responseData.shortCode}/${config.shlinkAppOpenMode}`; //document.getElementById("newButton").style.display = 'none'; //to be worked on //document.getElementById("cancelButton").style.display = 'block'; //to be worked on document.getElementById("p1qr-code").src = `${config.shlinkUrl}/${responseData.shortCode}/qr-code?size=160&format=png&margin=2&errorCorrection=L`; } }); }