Monday, May 20, 2024
4
rated 0 times [  10] [ 6]  / answers: 1 / hits: 53480  / 12 Years ago, fri, february 22, 2013, 12:00:00

chrome.tabs returns undefined despite the fact I set tabs in the permissions block.


"permissions": [
"tabs",
"http://*/*",
"https://*/*"
],
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"js/myScript.js"
],
"all_frames": true
}
],

But in myScript.js, chrome.tabs is undefined.


More From » google-chrome

 Answers
38

Content script can only use chrome.i18n, chrome.dom, chrome.storage, and a subset of chrome.runtime/chrome.extension.


Most chrome APIs such as chrome.tabs are only available the background script (service worker in MV3), popup script, etc.


Solution


Pass a message from the content script to the background script and use the API there.


[#80056] Thursday, February 21, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jazminkyrap

Total Points: 631
Total Questions: 89
Total Answers: 109

Location: Finland
Member since Fri, Oct 21, 2022
2 Years ago
;