0

I'm trying to use the browser APIs to get the current url, so that I can decide create a context menu if it's a certain URL.

I've seen a similar question on here but it doesn't seem to do what I'm expecting.

When using the tabs.query method, it always logs the same tab into the console (I have permissions added).

browser.tabs.query({currentWindow: true, active: true})
.then(tabs => {
    let tab = tabs[0];
    console.log(tab);
})
.catch(err => {
    console.error(err);
});

I would expect this to log a different tab to the console as I move from one tab to the next. Am I missing something?

davidpauljunior
  • 8,238
  • 6
  • 30
  • 54
  • That looks right. This code's in a background script? – Andy Dec 07 '18 at 22:02
  • Yeah in a background scripts. When I 'reload' the manifest in Firefox it will log the 'about:debugging' tab to the console. But when switching to any other tab, nothing gets logged. – davidpauljunior Dec 08 '18 at 07:27

0 Answers0