The problem here is that the "gotElement"
message is emitted before the listener is attached.
You can fix it with:
setTimeout(_ => self.port.emit("gotElement", document.location.href));
Afaict you don't need the contentScript, just do what you wanted to do in the onAttach
handler.