Reputation: 7736
I am developing a Extension-detect site that can detect whether the client has installed my extensions.
I try to load the manifest.json file so that I can know.
But when I tried, I got a:
Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.
So I put my website in the json, like:
"web_accessible_resources": [ "www.mysite.com/*", "mysite.com/*" ]
But it still doesn't work.
Is there anything I need to fix?
Thanks
Upvotes: 0
Views: 957
Reputation: 47833
web_accessible_resources
is a list of files packed in your extension that can be requested by any webpage loaded by your users browser. So if you want to load your manifest from your site you need an entry like this:
"web_accessible_resources": [ "manifest.json" ]
However this will allow any site your users visit to discover if your extension is installed so the recommended approach is to use a content_script that adds a class to the body of all the pages on your domain. That way your sites JS can check for the class for installation but no information will be accessible to other sites.
// content_script run on your domains
document.documentElement.classList.add('ext-name-installed');
On your site you can now check to see if the extension is installed with
// Run on website to test for extension
if(document.documentElement.classList.contains('ext-name-installed')) {
// Extension is installed
}
Upvotes: 1