-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I'm trying to call the SingleFile extension from a custom button that performs several actions that are typical in my workflow. My code in the background.js file is as follows:
const targetExtensionID = "{531906d3-e22f-4a6c-a102-8057b88a1a63}";
await browser.runtime.sendMessage(targetExtensionID, { action: "ACTION_SAVE_PAGE" })
.then(response => {
// Handle the response from the other extension if needed
recordLog("Received response from SingleFile extension: " + response);
})
.catch(error => {
// Handle any errors that may occur
recordError("Error sending message to SingleFile extension: " + error);
});
When I execute that code, I get the message "Received response from SingleFile extension: undefined", but nothing seems to happen. Any idea of what could be failing here?
It seems that the message is correctly sent to the SingleFile extension, as if I change the targetExtensionID then I get an error "Error sending message: Error: Could not establish connection. Receiving end does not exist.". This also begs another question: the target extension ID seems to be quite arbitrary (it is not even set in the manifest.json file of SingleFile, as far as I understand), so the code above seems to be quite fragile (it depends on an ID that has no meaning for me and could change). Any idea about whether this can be managed in a better way is welcome.
Any tip would be great!