Hacker News new | ask | show | jobs
by extraduder_ire 860 days ago
I'm surprised how short the source code for this is. I guess it doesn't have to do that much.
2 comments

Browser makers: creates carefully thought out security features

Junior Developers: what’s this do? Probably nothing… yeet

I haven’t read the source code but I assume it’s just a wrapper about BroadcastChannel.
It's a combination of chrome.runtime messaging api to establish a connection between the calling tab and the service worker and chrome.scripting api to actually execute on the target tabs. Tho you can only send json and not functions over the port so functions have to be stringified and the eval() on the tab main world. Since eval is not possible in extensions itself for good reason the only way is to do this on the tabs, so the tab filtering will also be done in a tab world and will respond the filtered tab ids back to the service worker.