0

Well, I need to access a variable that is in an extension's content script. I know that, normally, the reverse is done, that is, the content script is used to interact with the DOM, but I need to do the reverse...

Ex:

Content-script

const socket=io("http://127.0.0.1:1000")

index.html

<script> socket.on(...) </script>

Anyone knows how to acess these variables from DOM?

obs: This way of using the socket seems strange, but it was the only way I found to work around a problem I faced in manifest v3, which I need to connect to a socket directly through the dom (for reasons that do not fit in this topic), but in case I try to do this I am barred by the Content Security Policy. For some reason I can only connect the socket without being blocked by the CSP in the extension's content script and, as I said before, I need to access this socket through the dom, so I want to access this variable (socket) directly in the front-end.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197

0 Answers0