What is "injecting code into the main world"?
Can someone explain the concept of "injecting code into the main world"? Does this just mean adding new objects to the global window scope?
ref: https://discord.com/channels/946290204443025438/946290204904390690/1086103033919832064
11 Replies
@ceN
oops
sorry I pinged in you the wrong post lol
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
@ceN has reached level 1. GG!
But please ask questions in these section - will make it easier for folks to search in the future
cuz stuffs in #lounge get lost quick
Can you also post your other question in another post as well
But anyway - there're 2 worlds a content script can live in
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
one is the default "ISOLATED" world, in this world you have access to some chrome extension API, but not all (you will need to pipe them to bgsw if need more power). You don't have access to the same global context as the website - i.e, your window object will not share context
the other is the "MAIN" world, in this world, you have no access to chrome extension API, and will need toe pipe message (with relay) to send data between the site and extension API. In main world, you get full access to the webstie's global context and share context with it
we might make some in the future - the available official docs around these browser API concept are still pretty murky atm
Here's the official V8 docs: https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/bindings/core/v8/V8BindingDesign.md
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
@ceN has reached level 2. GG!
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
cookie is available in the isolated world if you request host_permission with that site, but yeah mainWorld should have everything, but it might be flaky. If you're down to do some experiment on that front - would love to add your finding to the docs
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View