I have a problem with my manifest.json for an Google Chrome extension. I want to load an script in the background. When I want to load the extension i get an syntax error, caused by the colon in line 10. I have looked in the Google Chrome Developer Documentation, but I don't find any helpfully information. Can you help me :D
{
"name": "Test",
"version": "1.0",
"manifest_version": 2,
"description": "Test",
"browser_action": {
},
"permissions": [["webRequest","webRequestBlocking",
"*://*.Test.com/*/*" ],
**"background": {**
"scripts": ["background.js"]
},
]
}
Your JSON is invalid and you really do have a syntax error. It looks like you tried to make the background part of the permissions array but here is what it should look like.
{
"name": "Test",
"version": "1.0",
"manifest_version": 2,
"description": "Test",
"permissions": [
"webRequest",
"webRequestBlocking",
"*://*.Test.com/*/*"
],
"background": {
"scripts": ["background.js"]
}
}
Keeping your JSON well formated will often help prevent mistakes like this. Good luck with your extension.
Related
I've been learning how to make a Chrome extension and have been stuck on just adding an icon for a while now, I've copy pasted code that supposedly works but I keep getting this error:
Could not load icon 'icon16.png' specified in 'icons'.
Could not load manifest.
My code:
{
"manifest_version": 3,
"name": "extension",
"description": "test",
"version": "1.0",
"browser_action": {
"default_icon": "icon48.png"
},
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
"content_scripts": [
{
"js": [
"test.js"
],
"matches": [
"https://www.test.com/*"
]
}
]
}
I've triple checked that every image is in fact a PNG and is of the right size. I have a single directory with manifest.json, test.js, and all three images (as well as a.prettierrc file, although I doubt that has any impact).
If I remove the icons part of manifest.json the extension works perfectly.
The error about not being able to load the manifest is likely related to:
"browser_action": {
"default_icon": "icon48.png"
},
which is from Manifest Version 2. The "browser_action" field should be changed to:
"action": {
"default_icon": "icon48.png"
},
For further reference see here: Action API unification
I started building chrome extensions. Initially I started with a simple extension which prints the hello in background console. How can I print that in the active window console.
This is my manifest.json file
{
"manifest_version": 2,
"name": "example",
"version": "0.1",
"description": "My Chrome Extension",
"icons": {
},
"background": {
"scripts": ["js/background.js"]
},
"browser_action": {
"default_title": "My test Environment"
},
"permissions": [
"background",
"storage",
"tabs",
"http://*/*",
"https://*/*"
]
}
This is the content of my background.js file
a simple
console.log("hello");
Take a look at Content Script, you could use manifest.json injection or Programming injection to ensure your code run in the context of current webpage.
The former requires Message Passing or Storage to ensure communications between content script with background page;
while as for the latter, Try the following code in background.js
chrome.tabs.executeScript({code: "console.log('hello');"});
Hopefully this is something simple. I'm testing a simple Chrome Extension script and it appears it'll execute part of the script, but won't complete it. For example, if I add an alert() to the beginning of a script, it will execute the alert. But if I place it after anything calling the chrome DOM object, it won't execute. Here's an example:
Will execute alert
alert("Test");
chrome.webRequest.onCompleted.addListener(function (request) { });
Will not execute alert
chrome.webRequest.onCompleted.addListener(function (request) { });
alert("Test");
Am I missing something?
Here is my manifest:
{
"background": {
"persistent": true,
"scripts": [
"scripts/libs/jquery.1.11.2.min.js",
"scripts/background.js"
]
},
"browser_action": {
"default_icon": "resources/icon.19.png"
},
"icons": {
"48": "resources/icon.48.png"
},
"manifest_version": 2,
"name": "Test",
"permissions": [
"<all_urls>",
"webNavigation",
"webRequest",
"webRequestBlocking"
],
"version": "1.0"
}
You are missing debugging it yourself.
Go to chrome://extensions/ and load the Dev Tools for your background page. You will see an uncaught exception that stops execution.
For webRequest events, you must include a filter argument to the addListener function.
i am facing an odd problem when i try to publish my chrome extension via the web store. Every time i upload the zip file i get this error:
An error has occurred: Can not contain the access permissions to the file.
I even tried to upload a zip file that contains only the manifest file but i am still having the same error.
Any idea ?
Thanks
Manifest file :
{
"name": "__MSG_plugin_name__",
"version": "0.0.0.1",
"manifest_version": 2,
"description": "__MSG_plugin_description__",
"browser_action": {
"default_icon": "images/ST_19.png",
"default_title": "__MSG_plugin_title__",
"default_popup": "popup.html"
},
"icons":{
"16": "images/ST_16.png",
"48": "images/ST_48_1.png",
"128": "images/ST_128.png"
},
"default_locale": "en",
"permissions": [
"contextMenus",
"tabs", "http://*/*", "file:///*","https://*/*", "ftp://*/*"
],
"background": {
"persistent": false,
"scripts": ["scripts/jquery.min.js","scripts/utils.js", "scripts/menus.js","scripts/logic.js"]
}
}
So i isolated the thing: ""file:///*"" was wrong and since i want the extension to run on any opened url, i used "" as a permission.
Change in the manifest file is :
"permissions": [
"contextMenus",
"tabs", "<all_urls>"
]
Thanks everybody
Yes, ndongo is correct and Chrome is complaining that it does not have a domain or path (just like the other protocols).
The way you must write your URLs must be protocol://domain/path (note you can use * or ?)
So you can replace "file:///*" with "file:///*/*" or use "<all_urls>"
I am using Chrome 21. Everything is working fine but I am getting this warning message -
"Support for manifest version 1 is being phased out. Please upgrade to version 2.". If I am updating manifest version 2 my script.js is not working. I am getting wrong result for my plugin. How to solve this problem ? Could somebody please help me out..
MANIFEST FILE:
{
"name": "Email_Extension",
"version": "1.0",
"manifest_version": 1,
"icons": {
"16": "EOE(16x16).png",
"48": "EOE(48x48).png",
"128": "EOE(128x128).png"
},
"description": "Eyes On Emails New",
"permissions": [
"http://api.eyesonemails.com/","http://192.168.0.197/","http://www.sagaciousinfosystems.com/","tabs"
],
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"css": ["style.css"],
"js": ["jQuery 1.7.1.js","script.js"]
}
],
"background": {
"page": "background.html"
},
"browser_action": {
"default_title": "Eyes on Emails",
"default_icon": "EOE(48x48).png"
},
"web_accessible_resources": [
"images/loader.gif",
"images/email-wrong.png",
"images/email-correct.png",
"images/eye-icon.png"
],
"options_page": "options.html"
}
Please refer to "Changes between version 1 and 2" section of this documentation page. All necessary changes you'll have to make in your extension are described there.
"manifest_version" should be assigned to 2, your mainfest.json should appear like that
{
"name": "Email_Extension",
"version": "1.0",
"manifest_version": 2,
...
}
check the documentation for chrome extension upgrade.