简体   繁体   中英

chrome.tabs is not present in chrome object

I am adding this listener in background.js file which is a background script

chrome.tabs.onActivated.addListener( function(info) {
     chrome.tabs.get(info.tabId, function(tab) { 
            chrome.tabs.reload(); 
     }); 
});

But in the chrome object tabs are not there.

The manifest file is

    {
      "name": "Tab Logger",
      "description": "Logs the clicked tabs with time",
      "version": "0.1",
      "manifest_version": 2,
      "app": {
        "background": {
          "scripts": ["background.js"]
        }
      },
      "permissions": [
          "tabs"
        ],


"icons": { "16": "calculator-16.png", "128": "calculator-128.png" }
}

Can anybody tell me what am I doing wrong?

chrome.tabs API is not listed as supported for Apps, and your manifest is for an app and not an extension.

You will need to either make an extension, or not use tabs API.


To convert your manifest to an extension simply change

  "app": {
    "background": {
      "scripts": ["background.js"]
    }
  },

into

  "background": {
      "scripts": ["background.js"]
  },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM