I want to save the url of the current tab but when I execute the code it doesn't save the url in the variable.
/* global var */
var currentURL;
function getCurrentURL() {
chrome.tabs.query({ active: true, currentWindow: true}, function(tabs) {
var tab = tabs[0];
currentURL = tab.url;
});
}
function addChannel() {
}
document.addEventListener('DOMContentLoaded', function () {
getCurrentURL();
console.log(currentURL);
if (currentURL !== "https://www.youtube.com/channel/*") {
document.getElementById('addChannel').remove();
}
else {
document.getElementById('addChannel').addEventListener('click',
function() {addChannel();});
}
})