I have tabs permission, from my sidebar I'm running the following code:
var currentUrl ='';
getPage();
function getPage(){
browser.tabs.query({currentWindow: true, active: true})
.then((tabs) => {
currentUrl = tabs[0].url;
})
}
The return is: about:debugging#/runtime/this-firefox
after reading some answers on this sub, I supposed it would return the current tab URL, what is the problem?
update: after reloading the add-on multiple times, it is now correctly reading the first current url, however it is not updating it as I navigate, here is the other half of sidebar code:
let btn_main = document.getElementById("btn_main");
btn_main.addEventListener("click", () => {
LiveConsole(currentUrl);
});
//show debug messages on the sidebar since console.log is not working
function LiveConsole(message){
var tag = document.createElement("p"); // <p></p>
var text = document.createTextNode(message);
tag.appendChild(text); // <p>TEST TEXT</p>
var element = document.getElementById("debug");
element.appendChild(tag); // <body> <p>TEST TEXT</p> </body>
}
update: added the window.onload = getPage;
but still it is not being run after every page load / news url visited etc...