Get tab URL from page action (WebExtensions, Android)

后端 未结 2 1011
失恋的感觉
失恋的感觉 2020-12-11 16:14

I would like to get the URL of the current tab within a page action popup.
At first it seems obvious: Just use the tabs API. But that doesn\'t seem to be available on An

2条回答
  •  醉酒成梦
    2020-12-11 16:43

    You can get it this way with webextensions. Take into account that if you want to debug a popup, you have to "prevent popups to be closed" (4-squares icon at the top-right of the browser's toolbox)

    var activeTabPromise = browser.tabs.query({active: true, currentWindow: true});
          activeTabPromise.then((tabs) => {
    
              console.log(tabs[0].url);
          });
    

    I hope this will help you,

提交回复
热议问题