I am trying to create a google extension that keeps track of the current and previous tab URLs a user visits. Is there a way to use Javascript to have the chrome extension run in the background check the current tab and return the URL?
My current HTML:
<body>
<div class="container">
<h2> Current Tab </h2>
<div id = "current_url"></div>
<h2> Previous Tab </h2>
<div id = "previous_url"> </div>
</div>
</body>
I tried doing:
document.getElementById("current_url").innerHTML = window.location.href;
but it does not update when I switch to a new tab.