{"id":2214,"date":"2022-08-30T15:23:00","date_gmt":"2022-08-30T15:23:00","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/04\/chrome-manifest-json-syntax-error-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:23:00","modified_gmt":"2022-08-30T15:23:00","slug":"chrome-manifest-json-syntax-error-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/chrome-manifest-json-syntax-error-collection-of-common-programming-errors\/","title":{"rendered":"Chrome Manifest.json syntax error-Collection of common programming errors"},"content":{"rendered":"<p>I am working on a chrome app and its basically done, however I am adding code to my customer&#8217;s website to have it determine if the app is installed on chrome or not.<\/p>\n<p>In order to do this I need to check for a file &#8220;manifest.json&#8221; is available for the app to determine if its installed or not.<\/p>\n<p>I am using the below code that I got from another posted question on here:<\/p>\n<pre><code>function detectChromeExtension(extensionId, accesibleResource, callback){\n            if (typeof(chrome) !== 'undefined'){\n                var xmlHttp = new XMLHttpRequest(),\n                    testUrl = 'chrome-extension:\/\/' +extensionId +'\/' +accesibleResource;\n                    xmlHttp.open('HEAD', testUrl, true);\n                xmlHttp.setRequestHeader('Content-type', 'application\/x-www-form-urlencoded');\n                xmlHttp.timeout = 1000;\n\n                xmlHttp.onreadystatechange = function() {\n                if (xmlHttp.readyState == 4 &amp;&amp; typeof(callback) == 'function') {\n                    if (xmlHttp.status == 200) {\n                        callback.call(this, true);\n                    } else {\n                        callback.call(this, false);\n                    }\n                }\n            }        \n            xmlHttp.ontimeout = function() {\n                if (typeof(callback) == 'function')\n                    callback.call(this, false);\n                }        \n                xmlHttp.send();\n            } else {\n                if (typeof(callback) == 'function')\n                    callback.call(this, false);\n            }    \n        };\n\n        detectChromeExtension('gcjbmhbihobfgpjmfbooldocijijdpig', 'manifest.json', myCallbackFunction);\n\n        function myCallbackFunction(extensionExists) {\n            if (extensionExists){\n                console.log('Extension present');\n            } else {\n                console.log('Extension not present');\n            }\n        }\n<\/code><\/pre>\n<p>By checking the chrome console I am getting the following output:<\/p>\n<p>Denying load of chrome-extension:\/\/gcjbmhbihobfgpjmfbooldocijijdpig\/manifest.json. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.<\/p>\n<p>so to fix this I am trying to add &#8220;web_accessible_resources&#8221;: [&#8220;manifest.json&#8221;] into my manifest.json but it tells me that this line doesn&#8217;t follow syntax.<\/p>\n<p>Here is the full manifest.json:<\/p>\n<pre><code>{\n\"name\": \"Watch TBR\",\n\"version\": \"1.0\",\n\"manifest_version\": 2,\n\"default_locale\": \"en\",\n\"description\": \"Easy access to WatchTBR.com\",\n\"icons\": { \"128\": \"icon_128.png\", \"16\": \"icon_16.png\" },\n\"app\": {\n\"urls\": [\n  \"http:\/\/www.watchtbr.com\/\"\n],\n\"launch\": {\n  \"web_url\": \"http:\/\/www.watchtbr.com\/\"\n}\n},\n\"web_accessible_resources\": [\"manifest.json\"],\n\"permissions\":[\"http:\/\/www.watchtbr.com\"]\n}\n<\/code><\/pre>\n<p>Any help on this is greatly appreciated.<\/p>\n<ol>\n<li>\n<p>Unlike extensions, there is no way for a website to access packaged app&#8217;s resources. If you own both the site and the app, you can use the inline installation feature of Chrome WebStore and test if the app is installed with <code>chrome.app.isInstalled<\/code>.<\/p>\n<p>At the moment, the <code>isInstalled<\/code> method is limited to hosted apps, but this bug tracks the packaged apps support.<\/p>\n<p>If you don&#8217;t own the app or just want to share a link to the app (if installed) or to the store entry (if not installed), there is a feature request you can star and track progress at https:\/\/code.google.com\/p\/chromium\/issues\/detail?id=161054<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-01-04 14:19:53. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am working on a chrome app and its basically done, however I am adding code to my customer&#8217;s website to have it determine if the app is installed on chrome or not. In order to do this I need to check for a file &#8220;manifest.json&#8221; is available for the app to determine if its [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2214","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2214"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2214\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}