mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2024-11-22 19:50:12 +00:00
fix backgound.js listener callback, take 3
This commit is contained in:
parent
1dd2d503cc
commit
aff7c50f94
@ -116,21 +116,25 @@ async function downloadLink(toDownload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// event listener for messages from script.js and popup.js
|
// process and return message if needed
|
||||||
browserType.runtime.onMessage.addListener(
|
function handleMessage(request, sender, sendResponse) {
|
||||||
(data, sender) => {
|
console.log("message background.js listener: " + JSON.stringify(request));
|
||||||
console.log("message background.js listener: " + JSON.stringify(data))
|
|
||||||
if (data.verify === true) {
|
if (request.verify === true) {
|
||||||
let response = verifyConnection()
|
let response = verifyConnection();
|
||||||
return Promise.resolve(response);
|
response.then(message => {
|
||||||
} else if (data.youtube) {
|
sendResponse(message);
|
||||||
setYoutubeLink(data)
|
})
|
||||||
} else if (data.download) {
|
} else if (request.youtube) {
|
||||||
let response = downloadLink(data.download.url)
|
setYoutubeLink(request)
|
||||||
return Promise.resolve(response);
|
} else if (request.download) {
|
||||||
|
let response = downloadLink(request.download.url);
|
||||||
|
response.then(message => {
|
||||||
|
sendResponse(message)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
browserType.runtime.onMessage.addListener(handleMessage);
|
||||||
|
Loading…
Reference in New Issue
Block a user