I'm developing a Chrome extension, is there any way to get the chrome.extension.getURL('file path')
method from injected file? I'm unable to access above method from injected file.
manifest.json
{
"name": "Name",
"version": "0.1",
"description": "Name chrome extension",
"background": {
"persistent": false,
"scripts": ["js/background.js"]
},
"permissions": [
"tabs",
"https://*/*"
],
"content_scripts": [
{
"matches": ["https://mail.google.com/*"],
"js": ["js/content.js"],
"run_at": "document_end"
}
],
"web_accessible_resources": [
"js/injected.js",
"html/popup.html"
],
"manifest_version": 2
}
injected.js
console.log("Ok injected file worked");
console.log("Url: ", chrome.extension.getURL('html/popup.html'));
contentScript.js
var s = document.createElement('script');
s.src = chrome.extension.getURL('js/injected.js');
(document.head || document.documentElement).appendChild(s);