I developed Edge extension and sideload it.
But there was an error.

How I solved the error?
I just added “return true;” at the end of the content script code to be injected.
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
$("body").prepend(
`<img src="${request.url}" id="${request.imageDivId}"
class="slide-image" /> `
);
$("head").prepend(
`<style>
.slide-image {
height: auto;
width: 100vw;
}
</style>`
);
$(`#${request.imageDivId}`).click(function() {
$(`#${request.imageDivId}`).remove(`#${request.imageDivId}`);
});
sendResponse({ fromcontent: "This message is from content.js" });
return true;
});
ChatGPT says the AddListener is not an ansync method, so this solution may not work. But it worked! I’m happy. I need to understand more about JavaScript.
Use Developer Tools for debugging
I’m really entry level developer for web development. Today I knew this “Developer Tools” is so useful for developing.
To get this, Go to … button > More Tools > Developer Tools.
I could see the image tag in Element section that is added in the extended script.

Leave a comment