Answer the question
In order to leave comments, you need to log in
Does Chrome extension worker either work or not?
Hello!
The extension should respond to certain XHR requests, but for some reason it can suddenly fall off, and resumes work if you start the worker's debug console. While the console is running, it works without failures.
If the console is turned off, the extension may fall off again.
extract from the manifest:
"manifest_version": 3,
"background": {
"service_worker": "background.js"
},
"permissions": [
"storage",
"scripting",
"webRequest",
"webRequestBlocking",
"tabs"
],
"host_permissions": ["https://secret"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content-script.js"]
}
],
chrome.webRequest.onCompleted.addListener(function (details) {
console.log({details})
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
console.log({tabs})
if (tabs[0]) {
chrome.tabs.sendMessage(tabs[0].id, {details}, function(response) {
console.log({response});
});
}
});
}, {urls: ['https://secret/?*']});
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
console.log(request);
sendResponse({});
}
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question