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"

Just change "browser_action" to "page_action" in the manifest.json.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With