3

The popup.html file is not opening when I click the extension button. The chrome extension is also changing the newTab through the main.html file. But the popup does not show, neither does the "inspect Pop Up" button. Why is this happening?

Manifest.json:

{
  "name": "Name",
  "description": "Add description",
  "version": "0.1.9.2",
  "browser_action": {
    "default_icon": "icon.png",
   "default_popup": "popup.html"
 },
  "permissions": [
    "activeTab"
  ],
  "chrome_url_overrides" : {
    "newtab": "main.html"
  },
  "background": {
    "scripts": ["jquery-2.2.3.min.js", "background.js"],
    "persistent": false
  },
  "icons": { "16": "icon16.png",
            "24": "icon24.png",
              "32": "icon32.png",
           "48": "icon48.png",
           "64": "icon64.png",
          "128": "icon128.png",
          "256": "icon256.png",
          "512": "icon512.png"
         },

  "permissions": [
    "activeTab",
    "https://ajax.googleapis.com/",
    "storage",
    "tabs",
    "http://*/*",
    "https://*/*"
  ],
  "browser_action": {
    "default_title": "app"
  },
  "manifest_version": 2
}

Popup.html:

<!doctype html>
  <html>
   <head>
    <style type="text/css">
        body {
            width: 200px;
            height: 200px;
        }
    </style>
   </head>
   <body>
    TEXT TEXT TEXT
   </body>
  </html>
I-Parliament
  • 115
  • 1
  • 7

1 Answers1

3

You have 2 browser_action sections in your manifest:

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },

  ...

  "browser_action": {
    "default_title": "app"
  },

When the manifest is parsed, it's not a syntax error* but the second one overwrites the first one. So you no longer have a default_popup.

You should merge them into one key:

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html",
    "default_title": "app"
  },

* Technically, duplicate keys are not disallowed by the JSON standard: SHOULD but not MUST have no duplicate keys; as such, implementation-dependent.

Community
  • 1
  • 1
Xan
  • 74,770
  • 16
  • 179
  • 206
  • 2
    For future readers of this answer, starting from [manifest v3](https://developer.chrome.com/docs/extensions/mv3/intro/), the key is simply ["action"](https://developer.chrome.com/docs/extensions/reference/action/) as opposed to "browser_action" in manifest v2. – bordeaux Apr 17 '21 at 13:28