0

I can't find any working code since getSelected is depreciated. But can anyone help me with how to achieve this?

chrome.action.onClicked.addListener((tab: chrome.tabs.Tab) => {
  const urlTab: string = tab.url as string;
  console.log(urlTab)
});

chrome.tabs.onActivated.addListener((activeInfo: chrome.tabs.TabActiveInfo) => {
  const tabId: number = activeInfo.tabId;
  chrome.tabs.get(tabId, (tab: chrome.tabs.Tab) => {
    const urlTab: string = tab.url as string;
    console.log(urlTab)
  });
});

If I have this in background.js, how can I pass the urlTab in popup.js? Thank you for helping me.

TBA
  • 1,921
  • 4
  • 13
  • 26
user16691768
  • 93
  • 1
  • 8
  • chrome.action.onClicked won't work if your popup is defined in default_popup. Simply query the tab in your popup script directly: [How to get the currently opened tab's URL in my page action popup?](https://stackoverflow.com/q/10413911) – wOxxOm Oct 21 '21 at 09:47
  • Im using manifest v3 and `runtime.getBackgroundPage()` not available . – user16691768 Oct 21 '21 at 18:00
  • You don't need it. – wOxxOm Oct 21 '21 at 18:01

0 Answers0