Submitted Chrome extension: "manifest is invalid" on download - google-chrome-extension

I recently submitted a chrome extension, but when I try to download the extension it says that the manifest file is invalid. Not sure why.
Here is my manifest :
{
"name": "My chrome extension",
"version": "0.2",
"description": "My chrome extension description.",
"permissions": [ "activeTab", "tabs", "contextMenus" ],
"background": {
"persistent": false
},
"browser_action": {
"default_icon": "favicon.png",
"default_popup": "index.html"
},
"manifest_version": 2
}
Is there a tool online where I can validate a Chrome extension manifest file?

You are missing scripts in your background item.
{
...
"permissions": [ "activeTab", "tabs", "contextMenus" ],
"background": {
"scripts": [
"path/to/js/script",
],
"persistent": false
},
"browser_action": {
"default_icon": "favicon.png",
"default_popup": "index.html"
},
...
}
OR just remove the background item from your manifest if you are not planning on using it.
{
...
"permissions": [ "activeTab", "tabs", "contextMenus" ],
"browser_action": {
"default_icon": "favicon.png",
"default_popup": "index.html"
},
...
}
--
You don't need tools to test the manifest, go to the chrome://extensions page, enable developer mode on the top right and load your extension, it will tell you the error and how to solve it.

Related

Get network data in chrome extension

I have a chrome extenison but i can't figure out how to access the data in the devtools network tab and send to the popup. Any suggestion?
it's basically a bug reporting chrome extension where you can take screenshots, create issue, and I need the network log (and/or console)
manifest.json
{
"manifest_version": 2,
"name": "my-chrome-extension",
"description": "Chrome Extension for report bug",
"version": "1.0",
"background": {
"scripts": [
"js/background.js"
],
"persistent": false
},
"icons": {
"16": "./icon.png",
"36": "./icon.png",
"48": "./icon.png",
"120": "./icon.png"
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"js/vendor.js", "js/content_script.js"
]
}
],
"web_accessible_resources": [
"inject-script.js",
"js/inject-script.js"
],
"browser_action": {
"default_popup": "popup.html",
"default_title": "PerfWatch"
},
"permissions": [
"tabs",
"activeTab",
"storage"
]
}
You cant access it directly. Only via API like webRequest via bg script.
Example:
chrome.webRequest.onBeforeRequest.addListener((details) => {
//This identifies a redirect to another page
if (details.url.indexOf("Target") && details.method === "OPTIONS/..." && details.initiator.indexOf("Source")) {
chrome.tabs.sendMessage(details.tabId, {
message: "xyz"
});
}
})
Your manifest.json must include the webRequest permission in order to access the webRequests:
{
"manifest_version": 2,
"name": "my-chrome-extension",
"description": "Chrome Extension for report bug",
"version": "1.0",
"background": {
"scripts": [
"js/background.js"
],
"persistent": false
},
"icons": {
"16": "./icon.png",
"36": "./icon.png",
"48": "./icon.png",
"120": "./icon.png"
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"js/vendor.js", "js/content_script.js"
]
}
],
"web_accessible_resources": [
"inject-script.js",
"js/inject-script.js"
],
"browser_action": {
"default_popup": "popup.html",
"default_title": "PerfWatch"
},
"permissions": [
"tabs",
"activeTab",
"storage",
"webRequest"
]
}
Hint:
There are additional APIs like webNavigation and webRequestBlocking if you need more funtionallity.

How to port Chrome extension to Firefox addon?

I get this error in Firefox:
There was an error during the temporary add-on installation.
Error details ▼
File red_apples.zip does not contain a valid manifest
This is the extension I'm trying to port. Here's the manifest:
{
"manifest_version": 2,
"name": "Red Apples",
"permissions": [
"tabs", "activeTab"
],
"background": {
"persistent": false,
"scripts": [
"background.js"
]
},
"version": "0.0.0.2",
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
"browser_action": {
"default_icon": "icon16.png",
"default_title": "Red Apples",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"script.js"
]
}
]
}
At the bottom of this tutorial it says there's a 99% chance it works without modification, if it passes the test here. But it passes the test and still doesn't work.
I get the manifest error both for the version packed with Chrome, and for the version just compressed as .zip.

Chrome Extension blocks programmatic request to popup.html

After the release of Chrome 66, our specs for testing a Chrome Extension fail because we are unable to access the popup.html programmatically because the request to chrome-extension://<extension-id>/src/popup.html is blocked.
We've tried getting the extension ID programmatically using chrome.runtime.id and chrome.runtime.getURL().
We've also tried generating our own PEM to sign the extension and using the generated ID in the manifest as the extension key. Both of these attempts have proved fruitless.
Is there still a way to access Chrome Extension programmatically for testing?
Update: Here is my manifest.json:
{
"manifest_version": 2,
"name": "Paparazzi",
"version": "1.0.9",
"background": {
"matches": ["<all_urls>"],
"scripts": [
"src/background.js",
"vendor/jszip.js",
"vendor/FileSaver.js",
"vendor/mixpanel.js"
]
},
"browser_action": {
"default_icon": {
"16": "ic-paparazzi-16.png",
"48": "ic-paparazzi-48.png",
"96": "ic-paparazzi-96.png",
"128": "ic-paparazzi-128.png",
"256": "ic-paparazzi-256.png"
},
"default_popup": "src/popup.html"
},
"commands": {
"capture_screen": {
"suggested_key": {
"default": "Ctrl+Shift+E",
"mac": "Command+Shift+E"
},
"description": "Capture screenshot of current tab"
}
},
"content_security_policy":
"script-src 'self' https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js; object-src 'self'",
"icons": {
"16": "ic-paparazzi-16.png",
"48": "ic-paparazzi-48.png",
"96": "ic-paparazzi-96.png",
"128": "ic-paparazzi-128.png",
"256": "ic-paparazzi-256.png"
},
"permissions": [
"activeTab",
"cookies",
"identity",
"identity.email",
"notifications",
"tabCapture",
"tabs",
"webRequest",
"webRequestBlocking",
"http://*/",
"*://*.sharethrough.com/*",
"*://localhost/*",
"<all_urls>"
],
"web_accessible_resources": [
"src/*",
"vendor/fonts/MetricWeb-Regular.woff",
"vendor/bootstrap.min.css"
],
"key": "bgcanlbkmndllogdnbohopfomoknmjmf"
}
I'm on Chrome 66.0.3359.117 and I was able to get files like this;
chrome.runtime.getURL("popups/popup.html");
window.open() succeed for getting it to open the page. It does not work when the folder or file is not specified under "web_accessible_resources".
"web_accessible_resources": [
"popups/*"
]
If the problem isn't with the manifest, then it's likely related to the testing software and not Chrome.

Unrecognized manifest key 'externally_connectable'

I get this error on extension page:
Unrecognized manifest key 'externally_connectable'.
This is my manifest:
{
"manifest_version": 2,
"name": "Publish",
"externally_connectable": {
"ids": ["*"],
"matches": ["*://*.example.it/*"]
},
"description": "example ext",
"version": "2.0",
"browser_action": {
"default_icon": "favicon.ico",
"default_popup": "popup.html"
},
"background": {
"page": "background.html"
},
"permissions": [
"http://www.example.it/", "tabs", "http://localhost/", "http://www.example.it/", "https://*/*", "http://*/*", "notifications", "background"
],
"web_accessible_resources": [
"img/example.png",
"img/bg_site.gif"
]
}
How do i solve it? I serched on BigG, no one wrote about this error...
You're running Chrome 26.0.1410.63, but this manifest key was added in version 29.
Sources:
History of the Chromium source code dealing with this manifest key
Bug for which this manifest key was added
If you have this error with a newer version of Chrome you might have made the same mistake I made - I had a space at the end of the key name (inside the quotes.)

Cannot read property 'onConnet'

I'm attempting to follow the documentation here to pass a variable from my background script, to my content script.
http://code.google.com/chrome/extensions/messaging.html
Manifest:
{
"name": "name",
"description": "desc",
"version": "1.0",
"manifest_version": 2,
"content_scripts": [
{
"matches": [ "http://*/*", "https://*/*" ],
"js": ["content.js"]
}
],
"background": {
"scripts": ["background.js"]
},
"permissions": [
"tabs",
"http://*/*",
"https://*/*"
],
"options_page": "options.html",
"browser_action":
{
"default_icon": "icon.png",
"default_title": "Settings",
"default_popup": "settingspanel.html"
}
}
background.js file:
chrome.extension.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
port.postMessage({counter: msg.counter+1});
});
});
content.js
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
sendResponse({counter: request.counter+1});
});
I receive an error on the background script that says "Cannot read property 'onConnect' of undefined"
Probably your problem is Issue #131623: Reloading extension while developer tools are open breaks chrome object and js console.
Until the fix gets through you have to close the Developer Tools before reloading the extension.

Resources