Getting url from active tab on external page

I have create a very simple addon for personal use. The only thing it does is show a “popup” with an external url. So far it works fine, but now I of course want to add features. For this I would like to access the url of the tab on which the extension is opened. I have tried many things, but I can’t seem to put my finger on it. I would also be glad with the url being added as a parameter to the url of “default_popup”.

This is my manifest.json:

{
  "browser_action": {
    "browser_style": true,
    "default_title": "Name of addon",
    "default_popup": "https://www.domain.com/dir/"
  },
  "icons": {
    "48": "lock.svg",
    "96": "lock.svg"
  },
  "description": "Open given page in window on top of browser I guess...?",
  "manifest_version": 2,
  "name": "Name of addon",
  "version": "1.0.11",
  "permissions": [
    "tabs"
  ],
  "applications": {
    "gecko": {
       "id": "name@domain.com"
     }
  }
}

It’s probably just a simple thing for you seasoned developers, but I have only started today :slight_smile:

To access only current tab info, you only need activeTab permission, no need to use the tabs permission (which is alerted to the user on installation).

Regarding getting current tab info from the popup script (or any other script) you can use:

const [tab] = await browser.tabs.query({active: true, lastFocusedWindow: true});
console.log('URL is:', tab.url);

Found my solution here: https://stackoverflow.com/a/66280454/842381

I also followed the advise on the permissions.