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?
Related
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.
I'm going to make a program that inserts HTML code into a specific tag on a web page through Chrome Extension MV3.
I would like to use jquery to do the above work. However, I searched on Google and found that it did not show how to do it in the Manifest V3 environment.
How do I get jquery from Chrome Extension Manifest V3?
//manifest.json
{
"name": "test",
"description": "Build an Extension!",
"version": "1.0",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
},
"permissions": ["storage", "activeTab", "scripting", "activeTab","tabs"],
"action": {
"default_popup": "popup.html"
}
}
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...
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
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"
]