After a lot of times spend to find the solution, i'm here to ask your help.
I have a simple chrome extension, and what I try to do is simple:
Detect on the page when a button is clicked, then, open the extension popup.html
.
A good example is MetaMask, the html page can open the popup to connect the wallet, send transaction ...
Thank you !
// Content Script button.addEventListener("click", () => { chrome.runtime.sendMessage("OpenPopup") })
// Background Script chrome.runtime.onMessage.addListener(request => { if (request == "OpenPopup") { chrome.windows.create({ url: "popup.html", type: "popup", focused: true, width: 400, height: 600, top: 0, left: screen.width - 400, }, () => { console.log("Opened popup!") }) } })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With