简体   繁体   English

chrome.tabs在chrome对象中不存在

[英]chrome.tabs is not present in chrome object

I am adding this listener in background.js file which is a background script 我在background.js文件中添加了此侦听器,这是一个后台脚本

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. 但是在chrome对象中,没有选项卡。

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. chrome.tabs API 未列为受应用程序支持 ,并且清单是针对应用程序而不是扩展程序。

You will need to either make an extension, or not use tabs API. 您将需要进行扩展,或者不使用tabs API。


To convert your manifest to an extension simply change 要将清单转换为扩展名,只需更改

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

into

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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