I have developed an extension and trying to upload it. but it gives error:manifest.json:34:1: an object must end with '}'.
Any help will be appreciated.
here is the content of manifest.json:
{
"manifest_version" :2,
"name": "Text to Speech",
"version" :"1.0.0",
"description" :"Indian language text to speech extension. Developed under TDIL programme by TTS consortium",
"options_page": "options.html",
"browser_action": {
"default_icon": { // optional
"19": "images/text2voice.png" // optional
},
"default_title": "Indian language TTS", // optional; shown in tooltip
"default_popup": "popup.html" // optional
},
"icons": { "16": "images/t2v-48.png",
"48": "images/t2v-48.png",
"128": "images/t2v-128.png" },
"background": {
"page": "background.html"
},
"content_scripts": [
{
"matches": ["<all_urls>"], //content script will be injected in all urls
"js": ["content_script.js"]
}
],
"permissions": [ //permitted to access following pages
"http://*/*",
"https://*/*",
"contextMenus",
"tabs"
]
}
Your comments such as //options is breaking your json. Please try to put the entire contents of manifest.json validator(http://jsonlint.com) and see the errors.
Related
[!["manifest_version": 2,
"icons": {
"16": "/images/icon16.png",
"48": "/images/icon48.png",
"128": "/images/icon128.png"
},
"browser_action": {
"default_icon": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"default_popup": "/screens/popup.html"
},
"permissions": \["tabs", "storage", "webNavigation"\],
"content_scripts": \[
{
"js": \["popup.js", "websites.js"\],
"matches": \[
"<all_urls>"
\]
}
\],
"background": {
"scripts": \["background.js"\],
"persistent": false
},
"content_security_policy": "script-src 'self' https://ajax.googleapis.com https://stackpath.bootstrapcdn.com; object-src 'self';"
}
I don't know why my chrome extension icon isn't showing. I saved all the icons into the images folder hence the /images. it is giving me the blue puzzle piece in the middle Is there something wrong with my code?
This example is working on my browser. I don't know why your manifest json starts with [![. Maybe this is the problem. I'm not sure. Can you edit this example according to your json file?
{
"manifest_version": 2,
"name": "Test",
"description": "Test",
"version": "1.0",
"browser_action": {
"default_icon": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"default_popup": "popup.html"
},
"permissions": [
"activeTab"
]
}
Try copy-pasting this into your manifest.json file. You have loads of artefacts that might cause issues, I also removed the default_icons key which isn't necessary in my opinion. Also removed the backslash / before the image folder-paths.
{
"name": "Some extension",
"manifest_version": 2,
"icons": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"browser_action": {
"default_popup": "/screens/popup.html"
},
"permissions": ["tabs", "storage", "webNavigation"],
"content_scripts": [{
"js": ["popup.js", "websites.js"],
"matches": [
"<all_urls>"
]
}],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"content_security_policy": "script-src 'self' https://ajax.googleapis.com https://stackpath.bootstrapcdn.com; object-src 'self';"
}
I had the same issues. I opened the png file(s) with paint and resaved them and it worked. So please verify your png files.
Here I have taken permission for all the needed thing, if something missing here please let me know.
Manifest.json
{
"manifest_version": 2,
"name": "SearchMood",
"description": "This extension shows Google Web Search and Google Image
Search result.",
"version": "1.4",
"author":"Searchmood",
"browser_action": {
"default_icon": {
"128": "icon-128.png",
"16": "icon-16.png",
"48": "icon-48.png"
},
"default_title": "SearchMood",
"default_popup": "background.html"
},
"chrome_url_overrides" : {
"newtab": "popup.html"
},
"icons": {
"128": "icon-128.png",
"16": "icon-16.png",
"48": "icon-48.png"
},
"background": {
"scripts": [ "background.js","popup.js" ]
},
"permissions": [
"activeTab","management","https://ajax.googleapis.com/"
],
"content_scripts": [
{
"matches": [ "http://search.searchmood.com/*" ],
"js": [ "js/restoremodal.js" ],
"all_frames": true,
"run_at": "document_start"
}
],
"externally_connectable": {
"matches": ["http://*.searchmood.com/*"]
}
}
Script on my web page I have:
<div class="links">
<ul>
<li>Terms&Conditions</li> |
<li>Privacy policy</li>|
<li>Contact US</li>
<li><span id="restoreLink" onclick="adi();">Reset Chrome</span></li>
</ul>
</div>
<script type="text/javascript">
function adi(){
var editorExtensionId = "pokioadkjpcbalcpfidmlebofahebkhb";
// Make a simple request:
chrome.runtime.sendMessage(editorExtensionId, {request: "uninstall"});
}
</script>
And this is the code in my extension to listen To this message I have put this code in popup.js. Please guide me where to put that also.
chrome.runtime.onMessageExternal.addListener(
function(request, sender, sendResponse) {
if (request == "uninstall") {
var id = chrome.app.getDetails().id;
chrome.management.setEnabled(id, false);
}
});
This the script I have written. I have some other codes also but that is also not working.
Yes I got the answer In the content Script File We can write code for taking the element from Website And their we will use SendMessage function Make sure You have taken permission for "Management" in manifest.json And persistent in Menifest.json should be "false".
Then you can use onmessage function and disable your extension Codes for your reference:
**HTML**`<span id="restorelink"> disable chrome extension</span>`
**menifest.json**
{
"manifest_version": 2,
"name": "name",
"description": "describe about you extension",
"version": "1",
"browser_action": {
"default_icon": {
"128": "icon-128.png",
"16": "icon-16.png",
"48": "icon-48.png"
},
"background": {
"scripts": [ "background.js"],
"persistent": false
},
"permissions": [
"management"
],
"content_scripts": [
{
"matches": [ "http://your site url where you want to apply the change, you can use more than one seperating with "," ],
"js": [ "restoremodal.js" ],
"all_frames": true
}
]
}
**restoremodal.js**
document.getElementById("restoreLink").addEventListener("click", adi);
function adi(){
chrome.runtime.sendMessage({ value: "anything"});
}
**Background.js**
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.value=="anything") {
var id = chrome.app.getDetails().id;
chrome.management.setEnabled(id, false);
}
});
{
"name": "Supreme Bot",
"description": "Automate the checkout process for supremenewyork.com!",
"version": "1.0.3",
"manifest_version": 2,
"permissions": ["*://*/*"],
"content_scripts": [
{
"matches": ["*://*.supreme.com/*"],
"js": ["jquery.js", "supreme.js"]
}
],
"browser_action": {
"default_icon" : "icon-16.png",
"default_title": "Enable/Disable"
},
"background": {
"scripts": ["background.js"],
"persistent": false
},
"icons": {
"16": "icon-16.png"
},
{ //this line is showing up as an error that says manifest is not valid json
//dictionary keys must be quoted
"name": "Supreme Bot",
...
"options_page": "options.html",
...
}
}
I am working on an autofill and auto-checkout bot for buying clothing. I am trying to add an options page so that I will be able to adjust sizes (code for that is in a different file). Line 25 column 6 says that there is a syntax error where dictionary keys must be quoted. Any ideas?
If you check the JSON sample here, that part after the comma should be followed by a "key" not a new pair of curly brackets. Try removing it so your JSON file looks like this:
{
"name": "Supreme Bot",
"description": "Automate the checkout process for supremenewyork.com!",
"version": "1.0.3",
"manifest_version": 2,
"permissions": ["*://*/*"],
"content_scripts": [
{
"matches": ["*://*.supreme.com/*"],
"js": ["jquery.js", "supreme.js"]
}
],
"browser_action": {
"default_icon" : "icon-16.png",
"default_title": "Enable/Disable"
},
"background": {
"scripts": ["background.js"],
"persistent": false
},
"icons": {
"16": "icon-16.png"
},
"name": "Supreme Bot",
"options_page": "options.html",
}
I'm sure that it is I tried with/without BOM and I still get this error :
{
"manifest_version": 2,
"default_locale": "en",
"name": "__MSG_ext_name__",
"description": "__MSG_ext_description__",
"version": "1.6.0",
"icons": {
"16": "icon_16.png",
"48": "icon_48.png",
"128": "icon_128.png"
},
"browser_action": {
"default_icon": "icon_19.png",
"default_popup": "popup.html"
},
"background": {
"page": "background.html"
},
"options_page": "options.html",
"permissions": [
"tabs"
],
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"scripts/content.js"
],
"run_at": "document_start",
"all_frames": true
}
]
}
I used a program to mass convert all my files in UTF-8, now it works, I think as 方 觉 said, the problem was coming from another file than the manifest.
this works fine in browserAction..
but when i switch it pageAction.. even the icon doesnot show up
background.html
<html>
<head>
<script>
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({'url':'http://google.com/search?q=site:'+window.location.host});
});
</script>
</head>
</html>
manifest.json
{
"name": "linkcheck",
"description": "check link.",
"version": "1.1.1",
"
background_page": "background.html",
"permissions": ["tabs", "http://*/*","https://*/*"],
"browser_action": {
"name": "linkcheck",
"default_icon": "icon.png"
},
"icons": {
"128": "icon128.png",
"48": "icon48.png"
},
"content_scripts": [
{
"matches": ["https://www.google.com/*"],
"js": ["myscript.js"],
"run_at": "document_end"
}
]
}
Well for pageAction, you would need to enter another manifest property:
{
"name": "My extension",
...
"page_action": {
"default_icon": "icons/foo.png", // required
"default_title": "Do action", // optional; shown in tooltip
"default_popup": "popup.html" // optional
},
...
}
Then you need to either hide or show.
chrome.pageAction.show(integer tabId)