Open mitra42 opened 6 years ago
We could inject a content script to run in the context of the webpage. The content script and background script can communicate. But there is no direct way of accessing background script objects from a content script (or a webpage). However the content script can tell the background script to pass an object which can be sent back and forth using the message passing API https://developer.chrome.com/extensions/messaging
Ok - I did something like this in the dweb-serviceworker extension, the message passing worked, although the browser limitations on serviceworkers stopped it being effective. I'll look at it, and we can implement after the conference.
This would be a good small project, to see if there is a way in for example dweb-archive/archive.html to only load dweb-transports bundle again if its not usable on the dweb-ext. It might not be possible (without making other things worse), but its worth some research.
On another thread, https://github.com/protocol/collab-internet-archive/issues/36 @parkan points me at https://github.com/ipfs-shipyard/ipfs-companion/blob/master/docs/examples/window.ipfs-fallback.html which looks like it is seeing if "ipfs" is loaded by an extension and if not then loads it as a script.
I'd like to see a fork of dweb-archive that edits archive.html to look for DwebTransports and DwebObjects and only loads them if they haven't already been loaded.
I would guess the approach would be to a: Test if this the code in that example works, b: If it works, then parameterise it as a function that takes two parameters (variable, scripturl) and apply it to DwebTransports and DwebObjects
Once that works we can probably split ipfs out of DwebTransports and load ipfs if, and only if, it has't already been loaded by either our extension or some other extension (like IPFS Companion)
I am not being able to access https://github.com/protocol/collab-internet-archive/issues/36. I will check https://github.com/ipfs-shipyard/ipfs-companion/blob/master/docs/examples/window.ipfs-fallback.html now.
There is not much in that thread. We were talking about how to make the dweb libraries recognize when the IPFS library is already loaded (by the IPFS extension) and only load the IPFS library when it isnt. The same technique makes sense for dweb-transports and dweb-objects, especially as it would speed up load times for each page, and ensure that IPFS stayed running between uses.
Is it possible for a webpage, loaded by the extension, to see any data in the extension.
In particular, if I could see the DwebTransports or DwebObjects loaded by the bundles, then I could use the IPFS & GUN instances in there, rather than having two version of IPFS running (one in the browser, one in the extension). Is this possible ?