GWorking
GWorking

Reputation: 4341

chrome extension chrome.tabs.getCurrent fails, chrome.tabs.query({active: true} works in a normal script with activeTabs permission

A simple chrome extension that replaces the new tab

"permissions": ["activeTab"]
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>_</title>
    <script src="test.js"></script>
  </head>
  <body>
    <div id="image"></div>
  </body>
</html>
let test = () => {
  console.log(document.getElementById('imagen'))
}

chrome.tabs.query({active: true}, test)
chrome.tags.getCurrent(test)

These instructions should be equivalent (?)

Upvotes: 0

Views: 55

Answers (1)

user8977154
user8977154

Reputation: 403

I'm quite positive that it's because you're calling chrome.tags instead of chrome.tabs.

The documentation is also very clear that it won't work on background or popup pages but from your example I don't believe this is the case.

Upvotes: 2

Related Questions