Chrome extension cannot load external javascript via manifest - javascript

I'm working on a Chrome extension that works with the Aviary API. I need to add the Aviary Javascript to the extension. Here's what my manifest looks like:
"content_scripts": [ {
"js": ["http://feather.aviary.com/js/feather.js", "jquery-1.7.2.min.js", "chosen/chosen.jquery.js", "main.js" ],
"css": [ "assets/css/style.css" ],
}],
"permissions": [
"http://feather.aviary.com*",
"tabs",
"cookies"
]
But it keeps throwing the error "Could not load javascript 'http://feather.aviary.com/js/feather.js' for content script." . Am I doing anything wrong? I've been searching around but haven't found the solution.

You should set permission example
"permissions": [
"http://*feather.aviary.com*", "webRequest",
"tabs"
]

Related

How to inject external js script in Chrome extension development

It seems that loading external CDN scripts is prohibited in Chrome Extensions Development Manifest V3.
It's a package called 'SweetAlert2' that I'm trying to load.
However, I heard that the external JS file is not loaded due to policy, so I downloaded the sweetalert js file and defined it in manifest.json. However, in a test environment, this package works as if it were not loaded.
[manifest.json]
{
"name": "Getting Started Example",
"description": "Build an Extension!",
"version": "1.0",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
},
"permissions": ["storage", "activeTab", "scripting"],
"action": {
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["contentscript.js", "sweetalert2.all.min.js"]
}
],
"web_accessible_resources": [
{
"matches": ["<all_urls>"],
"resources": ["template.html"]
}
]
}
The contentsscript.js file is loaded fine, but I wonder if the sweetalert2 package js file is not loaded.

Security error in firefox ext while fetching a file

While fetching a files contents with the following code in a background.js file:
function readFile(filename) {
let response = fetch(`file:///${filename}`);
console.log(response);
}
I get the following error:
Security Error: Content at moz-extension://86d386b7-2904-441f-8dbe-47f0af9b6bfb/_generated_background_page.html may not load or link to file:///C:/Users/rando/Downloads/jest-26.6.1.zip.
TypeError: NetworkError when attempting to fetch resource.
My manifest file looks like this:
"permissions": [
"webNavigation",
"webRequest",
"webRequestBlocking",
"cookies",
"tabs",
"http://*/*",
"https://*/*",
"ws://*/*",
"wss://*/*",
"storage",
"downloads",
"sessions",
"file://*/*"
],
"background": {
"scripts": [
"app/scripts/background.js"
],
"persistent": true
},
How do I solve this error and fetch the contents of the file using the background.js file?
Extension access to local file system file:/// has been blocked since Firefox 57 for security reasons.
Extensions can use the input type="file" to launch the file picker on user-click.
Extensions also can:
read files that are packed within the extension
communicate with a software on the local computer via Native messaging
get files via HTTP/s, if the localhost has a server running

Trying to insert JQuery to chrome extension gives error: "Could not load javascript 'jquery.js' for content script. Could not load manifest."

recently I came across an error during trying to get JQuery to my chrome extension. I wrote following code and then when I try to reload my extension in Chrome browser I get the message:
Failed to load extension
Error
Could not load javascript 'jquery.js' for content script.
Could not load manifest.
The file of jquery was downloaded from their webpage (compressed production 3.5.1).
I checked several webpages connected to this problem but I couldn't find the solution.
Files in which inserting JQuery matters are below:
manifest.json
https://ideone.com/EGKlfQ
"manifest_version": 2,
"name" : "name",
"version": "1.0",
"offline_enabled": true,
"content_scripts": [
{
"matches": [
"https://www.zalando-lounge.pl/*"
],
"js": ["jquery.js","content.js"]
}
],
"background" : {
"scripts": ["background.js"]
},
"browser_action":{
"default_icon": "img/icon.png",
"default_popup": "popup.html",
"default_title": "A popup will come here"
},
"permissions": ["tabs","storage"],
"content_security_policy": "script-src 'self' https://cdnjs.cloudflare.com/; object-src 'self'"
popup.html
https://ideone.com/exMgYq
<script type="text/javascript" src="jquery.js"></script>
...other code in this file doesn't matter in this case...

Google extension dosen't work after publish

Hi I made a little chrome extension for my self to use and wanted to publish it so i can put it on my portfolio.When i had it locally everything worked fine but after trying to download the publish version and trying to open the popup it says
"Your file was not found It may have been moved or deleted.
ERR_FILE_NOT_FOUND"
this is my manifest
{
"manifest_version": 2,
"name": "",
"description": "",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "index.html"
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"background",
"activeTab",
"storage",
"tabs",
"http://*/*",
"https://*/*"
]
}
these are my files that i compressed to upload
background.js
icon.png
index.html
main.js
manifest.json
style.css
I turned off all my other extensions to make sure it wasn't the other extension causing the problem

Cannot use webRequest on Chrome Extension

I am new in Chrome Extension development.
I have the following permissions in manifest.json
"permissions": [
"activeTab",
"https://ajax.googleapis.com/",
"webRequest",
"webRequestBlocking",
"tabs",
"webNavigation",
"management",
"http://*/*",
"https://*/*"
]
Also background entry and background.js file
"background": {
"scripts": ["background.js"],
"persistent": true
},
This background.js is included in popup.html head
<script src="background.js"></script>
And the problem is I can't add a listener in background.js script
chrome.webRequest.onHeadersReceived.addListener
chrome.webRequest.onBeforeRequest.addListener
I get the error background.js:1 Uncaught TypeError: Cannot read property 'onBeforeRequest' of undefined.
What I am doing wrong?

Categories

Resources