First let me begin by saying that I have googled this and checked various stack overflow posts for hours. If I missed something please leave a link to that question in your answer, otherwise please post a solution that corrects my code by telling me what to add and/or remove and specify the files that I should put these edits in. If my logic is wrong please point it out and show me a solution. This is my first Chrome Extension that I am working on. I am working with one other person and we are both stumped. Thanks so much for taking the time to help.
File: background.js:
function clicked() {
var i = prompt("This is a test"); // this runs
//this does not
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {file:"jquery.3.1.1.js"}, function() {
chrome.tabs.executeScript(null, {file:"content.js"});
});
});
}
chrome.browserAction.onClicked.addListener(clicked);
When I launch the chrome extension by clicking the icon the input box displays but the next few lines dont work. I get the following errors:
Unchecked runtime.lastError while running tabs.executeScript: Cannot access a chrome:// URL
Unchecked runtime.lastError while running tabs.executeScript: Cannot access a chrome:// URL
I omitted the random letter urls.
Here is manifest.json
manifest.json
{
"name": "not relevant",
"version": "1.0",
"manifest_version": 2,
"description": "Add description",
"browser_action": {
"default_icon": "icon.png"
},
"background": {
"scripts": ["background.js"]
},
"content_scripts": [ {
"js": [ "jquery-3.1.1.js", "content.js" ],
"matches": [ "http://*/*", "https://*/*"]
}],
"permissions": [
"background",
"activeTab",
"tabs",
"http://*/*",
"https://*/*"
]
}
The jquery file is in the same directory as these other files. I also have a content.js however I dont believe it has anything to do with the problem.
Also
before when I had the chrome.tabs.execute functions in background.js I tried to test the file with a .append statement the console gave me no errors but the page remained unchanged. The page is supposed to change the text content.