如何在Firefox中为所有页面元素实现内容转换器? [英] How can I implement a content converter in Firefox for all page elements?

查看:169
本文介绍了如何在Firefox中为所有页面元素实现内容转换器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



基本上,我需要的是,我需要一个Internet Explorer插件到Firefox,但我不知道在哪里寻找我需要的东西。能够使用特定的Content-Type头来过滤浏览器接收到的所有内容。我试着实现一个流转换器,这个工作,但只适用于页面,框架或iframe中的顶级文档。我也遇到了与IE相同的问题,并且绕过它真的很不方便,因为我希望这是跨平台的,所以我真的希望能够在不使用vtable黑客的情况下在Firefox中做到这一点。

b
$ b

内容以专有的压缩格式进行压缩。所以我需要接收数据,解压缩它,然后将Content-Type改回原始的未压缩文件。



如果有一种方法只是过滤所有收到的数据,这可能是可以接受的,我可以自己处理解析头。



谢谢

解决方案

我想我可能找到了我需要的东西。我遇到了这个链接,用于跟踪HTTP调用: http://blues.ath .cx / firekeeper / resources / http_tracer.html



由于某种原因,JavaScript实现似乎存在一些问题,我不是JavaScript大师来弄明白,但我已经在C ++中实现它,初步结果表明,我应该能够根据我的需要进行修改。



基本上我们正在取代nsIHttpProtocolHandler服务与我们自己的实现,保持参考初始实现。当对服务进行调用时,我们只需将它代理到保存的原始实现。然后我们提供我们自己的nsIHttpChannel和nsIStreamListener的实现,我们用它作为代理。

我们再次将大部分的调用代理回到原来的处理程序。但是在OnDataAvailable中,我们不是将数据传递给底层的nsIStreamListener,而是使用nsIStorageStream进行保存。然后在OnStopRequest中,获取所有数据之后,我们可以解压缩,然后在原始处理程序上调用OnDataAvailable,然后调用OnStopRequest。



它已经工作一些小的简单的测试到目前为止,但我必须通过一些更严格的测试...我也必须弄清楚,如果我可以用HTTPS做同样的事情。



我现在看到的最大的问题是它依赖于一些解冻的接口,如nsIHttpChannelInternal。尽管我可以告诉我,但是我的版本兼容性要求还是很小的,所以我可以忍受它。



同时,如果有人有任何其他的建议,我都听过:D

I'm attempting to port over an Internet Explorer plugin to Firefox, but I'm not sure where to look for what I need.

Basically I need to be able to filter all content that is received by the browser with a certain Content-Type header. I tried implementing a stream converter, and this works, but only for the top-level document in the page, frame, or iframe. I had the same problem with IE, and getting around it was really hacky, and since I would ideally like this to be cross platform I would really like to be able to do this in Firefox without resorting to vtable hacks.

The content is served compressed with a proprietary compression format. So I need to receive the data, decompress it, and change the Content-Type back to what the original uncompressed file should have.

If there is a way to just filter all data received, that would probably be acceptable, I could handle parsing the header myself.

Thanks

解决方案

I think I may have found what I needed. I came across this link which is used for tracing HTTP calls: http://blues.ath.cx/firekeeper/resources/http_tracer.html

There seems to be some problems with the JavaScript implementation for some reason, and I'm not a JavaScript guru to figure it out, but I've implemented it in C++ and initial results suggest that I should be able to modify it for my needs.

Basically we're replacing the nsIHttpProtocolHandler service with our own implementation, which keeps a reference to the initial implementation. When a call is made to the service, we just proxy it over to the saved original implementation. Then we provide our own implementation of nsIHttpChannel and nsIStreamListener which we use as proxies too.

Again we proxy most of the calls back off to the original handlers. But in OnDataAvailable, instead of passing the data on to the underlying nsIStreamListener, we save it using nsIStorageStream. Then in OnStopRequest, after we've gotten all of the data, we can decompress it and then call OnDataAvailable on the original handler, followed by OnStopRequest.

It has worked on some small simple tests so far, but I'll have to put it through some more rigorous tests... I'll also have to figure out if I can do the same thing with HTTPS.

The biggest problem I see at the moment is that it relies on some unfrozen interfaces such as nsIHttpChannelInternal. Can't be helped though as far as I can tell, and my version compatibility requirements are pretty small, so I can live with it if I have to.

In the meantime, if anybody has any other suggestions, I'm all ears :D

这篇关于如何在Firefox中为所有页面元素实现内容转换器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆