I am trying to develop a Chrome extension to open a new tab on button click and then execute js in it.
Manifest:
{
"author": "...",
"name": "...",
"manifest_version": 2,
"version": "1.0",
"description": "...",
"background": {},
"browser_action": {
"default_popup": "popup.html"
},
"permissions": [
"tabs","http://*/","https://*/"
]
}
popup.html:
<html>
<head>
<script src="jquery.min.js"></script>
</head>
<body>
<button type="button" id="saveBtn">Save</button>
<script type="text/javascript" src="popup.js"></script>
</body>
</html>
popup.js:
$("#saveBtn").click(function(){
chrome.tabs.create({
selected:false,
url:'https://analytics.google.com/something...'
},function(tab){
chrome.tabs.executeScript(tab.ib,{file:"jquery.min.js"});
chrome.tabs.executeScript(tab.ib,{file:"html2canvas.js"});
chrome.tabs.executeScript(tab.ib,{file:"FileSaver.js"});
chrome.tabs.executeScript(tab.id,{file:'inject.js'});
});
});
All javascript files are in the same folder. I am getting this error
Unchecked runtime.lastError while running tabs.executeScript: Cannot access a chrome:// URL at Object.callback (chrome-extension://jamfjopkccgnbpkhafanifhjambepphc/popup.js:8:23)
on lines where I am trying to inject jquery.min.js, html2canvas.js and FileSaver.js BUT NOT inject.js! New tab opens correctly, callback is executed but then the error is thrown. What am I doing wrong here?