I want to get the Current Tab Url at the start of execution of popup.js while the code execution does not move forward to the next lines, how to do that? This is my code :
let problemIndex = "";
let contestId = "";
let pathName = "";
let urlArr = [];
// Finding the Url of the Current Page
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
currentTab =(tabs[0].url);
console.log(currentTab);//1
});
console.log(currentTab);//2
//Finding ContestId && ProblemIndex
pathName = JSON.stringify(currentTab);
urlArr = pathName.split("/");
console.log(pathName);//3
if (urlArr[4] == "contest") {
contestId = urlArr[1];
} else {
contestId = urlArr[urlArr.length - 2];
}
problemIndex = urlArr[urlArr.length - 1];
I want execution of console.log() to be like 1 then 2 then 3 But the execution goes like this 2 then 3 then 1 . How to change this ?