I'm building an extension for firefox that sends a get request to local js server, the request contains the url to a youtube video, and the local server will open the video in mpv. Everything works, except for the part that makes the request, and i cant figure out how to do it.
- I've disabled cors on the recieving end.
- I added webRequest to the manifest.
- I tried using XMLHttpRequest and fetch.
- I know the casting function is called
- I know the url's im using are formatted correctly, because when i do a manual request in the browser they work as expected.
manifest.json:
{
"manifest_version": 2,
"name": "Youtube Caster",
"version": "1.0",
"description": "My own casting plugin",
"icons": {
"32": "icons/youtube-32.png"
},
"permissions": [
"*://www.youtube.com/*",
"activeTab",
"webRequest"
],
"browser_action": {
"browser_style": true,
"default_icon": "icons/youtube-32.png",
"default_title": "Caster",
"default_popup": "popup/cast_video.html"
}
}
my content script: (only showing the function that should be making the request)
function cast() {
const url = "http://127.0.0.1:8080/play?url="
const videoURL = window.location.href;
console.log("casting... ", url+videoURL)
fetch(url+videoURL);
}
I would expect the request to go through when the function is called, but it doesn't, my local server does not recieve anything.