Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error handling response: TypeError: Cannot read property 'show' of undefined at chrome-extension

At contentScript.js I put this code...

chrome.runtime.sendMessage({ todo: "showPage" });

and at backgroundScript.js

chrome.runtime.onMessage.addListener(function(request, sender, senderResponse) {
  if (request.todo == "showPage") {
    chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
      chrome.pageAction.show(tabs[0].id);
    });
  }
});

and this is the manifest.json file

{
  "manifest_version": 2,
  "name": "Startpage Chrome Extension",
  "description": "The extension will replace/load additional CSS and override Startpage default style, it should look exactly (or almost) like Google.",
  "version": "1.0.1",
  "author": "OpenText",
  "content_scripts": [
    {
      "matches": ["*://*.google.com/*"],
      "all_frames": true,
      "js": ["./jquery.js", "./startpage.js"],
      "css": ["startpage.css"],
      "run_at": "document_start"
    }
  ],
  "background": {
    "scripts": ["./jquery.js", "background.js"],
    "persistent": false
  },
  "icons": {
    "16": "icon.png",
    "48": "icon.png",
    "128": "icon.png"
  },
  "offline_enabled": true,
  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html",
    "default_title": "Startpage Extension"
  },
  "permissions": ["tabs", "activeTab", "storage", "*://www.google.com/*"]
}

this is the error I'm getting: "error handling response: TypeError: Cannot read property 'show' of undefined at chrome-extension://phgdcficdbmcpddkligkfkjjcognioik/background.js:17:25"

enter image description here

like image 910
Dee Jee Avatar asked Dec 19 '25 08:12

Dee Jee


1 Answers

Just change "browser_action" to "page_action" in the manifest.json.

like image 139
Back2Lobby Avatar answered Dec 20 '25 21:12

Back2Lobby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!