Improve downloader injection
The current way the downloader is injected into web pages leaves a lot to be desired. This issue is more of a tracking issue than one that provides a solution.
When a new page is opened, it must be able to download torrents by including the downloader code. This is currently accomplished by replacing the initial request with one of the injections found in ./lib/injection, the injection then makes a request for the actually requested content and displays it.
Some problems with this, iframes should not used form html pages, but there is no way to know definitively if the requested file is a html file (looking at the file extension only works if the extension is present). Using document.documentElement.innerHTML = text to replace the injectors html with the requested files html is a hack and can hopefully be improved. Ideally the improved injector would be less hacky, and be able to stream the requested content.
One potential improvement would be: if the requested file was html then edit the contents to include the downloader during planktos.fetch()
When a html file is requested, we can transform the files stream so our html injection code is included within the file stream. So when getBlob is called, it already contains the downloader code. This seems to me less hacky than the current way html injection is handled.
Some existing html parsers:
Trumpet may be the better choice because it takes care of the stream transformation for us.
@georgeaf99 you had the original idea of inserting the html injection into the requested file, is this something you'd like to tackle?
Yeah sounds cool! Lets figure out what the priority of this should be.