I'm trying to run a simple alert on newly created tabs.
A content script which alerts 'hello' works perfectly if the page is on a server for example http://www.google.com, but it doesn't work if the HTML page is hosted in the extension
manifest.json
{
"name" : "Alerter",
"description" : "Opens an alert !",
"version" : "1.0",
"manifest_version" : 2,
"background" : {
"scripts" : ["background.js"],
"persistent" : false
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["/js/content_script.js"]
}
],
"permissions" : ["tabs"]
}
content_script.js
alert('Hello!');
background.js
chrome.tabs.create({url:"/html/test.html"});
chrome.tabs.create({url:"http://www.google.com"});
test.html
<b> I am a file locally hosted on extension ! </b>
You will notice that the page of Google alerts a greeting message, while test.html doesn't.
Why is this happening, and how to execute the alert on 'test.html' ?
Edit based on 'valuable' post's comments:
If the documentation is wrong and we cannot inject code to chrome-extension urls, is there a workaround or alternative to achieve the same target ?