Doksuri
Doksuri
KPCKevin Powell - Community
Created by Doksuri on 10/29/2024 in #front-end
web extension fetch problem with firefox
Hi all, i just finished a tiny chrome extension, and wanted to post it for firefox too. the extension has only a popup page, and performs a simple fetch() request on a youtube account name (I.E. https://www.youtube.com/@anyAccountName) on firefox, i got a CORS problem. usually, i can solve the problem by adding headers. but i can't solve this one... The fun part, is that a fetch request on https://www.youtube.com works fine here is the manifest
{
"manifest_version": 3,
"author" : "me",
"name": "YT",
"description": "super description",
"version": "1.0",
"icons" : {
"48" : "img/icon-48.png",
"64" : "img/icon-64.png",
"128" : "img/icon-128.png"
},
"host_permissions":[
"https://*.youtube.com/*"
],
"action": {
"default_icon": "img/icon-48.png",
"default_popup": "popup.html"
}
}
{
"manifest_version": 3,
"author" : "me",
"name": "YT",
"description": "super description",
"version": "1.0",
"icons" : {
"48" : "img/icon-48.png",
"64" : "img/icon-64.png",
"128" : "img/icon-128.png"
},
"host_permissions":[
"https://*.youtube.com/*"
],
"action": {
"default_icon": "img/icon-48.png",
"default_popup": "popup.html"
}
}
and here is the popup.js
/* works fine */
fetch('https://www.youtube.com/');

/* fails (i tried multiple options) */
fetch(`https://www.youtube.com/@anyAccoundName`,{
mode: 'no-cors',
redirect: 'follow',
credentials: 'include',
referrerPolicy: 'no-referrer',
headers:new Headers({
'User-Agent': navigator.userAgent,
'Referer': 'https://www.youtube.com/'
})
});
/* works fine */
fetch('https://www.youtube.com/');

/* fails (i tried multiple options) */
fetch(`https://www.youtube.com/@anyAccoundName`,{
mode: 'no-cors',
redirect: 'follow',
credentials: 'include',
referrerPolicy: 'no-referrer',
headers:new Headers({
'User-Agent': navigator.userAgent,
'Referer': 'https://www.youtube.com/'
})
});
any help would be appreciated :/
13 replies
KPCKevin Powell - Community
Created by Doksuri on 10/17/2024 in #front-end
how to document.createRange().createContextualFragment(html) in a service worker ?
i'm working on a web extension, and it does a fetch. the result is the HTML, and i want to search elements in that HTML. usually, i do a createRange().. in order to be able to querySelector(). but since it's in a service worker. i don't have access to the document. how can i manage this ? thanks. here is my 'not working code'
fetch(myUrl)
.then(res => res.text())
.then(html => {
const page = document.createRange().createContextualFragment(html); // ReferenceError: document is not defined
});
fetch(myUrl)
.then(res => res.text())
.then(html => {
const page = document.createRange().createContextualFragment(html); // ReferenceError: document is not defined
});
1 replies
KPCKevin Powell - Community
Created by Doksuri on 9/27/2024 in #front-end
is it possible to set the scroll on a table and not its container ?
hi all, https://jsfiddle.net/n0x8e5L6/ in this example, i have a container with a table & a button. my button is hidden since my table is too long. is it possible to set a scroll on the table so my button is always visible ? i don't want to add an other container just for the table...
42 replies