I find it very discouraging developing firefox extensions! Nothing ever works! It’s so complicated to get things right.
I declared the content scripts in the manifest.json as follows:
"content_scripts": [
{
"matches": ["*://*/*"],
"js": ["/scripts/selection.js", "/scripts/sort.js", "/scripts/exif.js", "/scripts/RGraph.svg.common.core.js", "/scripts/RGraph.svg.line.js", "/scripts/search_results.js", "/scripts/exif_tags.js"]
}
]
I’m most concerned with the selection.js script at present. It should be receiving a message from the background script, but instead I’m getting the following error msg:
Error: “Could not establish connection. Receiving end does not exist.”
Furthermore, looking at the web console under the various open tabs I see no console logs at all. Yet, I have placed some console.logs in the script. It’s like something is preventing the content script from being loaded.
As per the MDN documentation, I then tried adding the following code to get the content script to load by calling register() if the value of registered is null:
async function register() {
registered = await browser.contentScripts.register({
matches: ["<all_urls>"],
js: [{file: "/scripts/selection.js"}],
runAt: "document_end"
});
}
but that doesn’t seem to work either! Help!..