在座有人有开发IE扩展的经验吗?这将包括代码示例,或链接到好的示例,或关于流程的文档,或任何东西。

我真的很想这么做,但我碰到了一堵巨大的墙,里面有糟糕的文档、糟糕的代码/示例代码/缺乏它们。你能提供的任何帮助/资源都将不胜感激。

具体来说,我想从如何从IE扩展中访问/操作DOM开始。

编辑,甚至更多的细节:

理想情况下,我想种植一个工具栏按钮,当点击时,弹出一个菜单,其中包含到外部网站的链接。我还想根据某些条件访问DOM并在页面上植入JavaScript。

在IE扩展中保存信息的最好方法是什么?在Firefox/Chrome/大多数现代浏览器中,你使用window。localStorage,但显然在IE8/IE7中,这不是一个选项。也许是SQLite DB之类的?可以假设。net 4.0将安装在用户的计算机上吗?

我不想使用Spice IE,因为我想构建一个与IE9兼容的IE。我也为这个问题添加了c++标签,因为如果用c++构建一个更好的话,我可以这样做。


当前回答

如果你不打算重新发明轮子,你可以试试IE的Add In Express。我已经使用该产品的VSTO的东西,它很好。此外,他们有一个有用的论坛和快速的支持。

其他回答

这个问题是从2013年开始,现在是2020年,但这可能对未来的游客有帮助。

我试着执行米格尔·安吉洛的回答,一开始并没有成功。

还有一些设置需要定义。

在ie浏览器上(我使用IE-11)进入工具-> internet选项->高级:

也可以看看这个SO问题和这个来自github的例子

The state for IE extensions is actually pretty sad. You have the old model of IE5 Browser Helper Object (yeah, those infamous BHOs that everyone liked to block back in the day), toolbars and the new accelerators for IE. Even then, compatibility will break sometimes. I used to maintain an extension for IE6 that broke with IE7, so there are some things that have changed. For the most part, as far as I know (I haven't touch BHOs in years) you still need to code them using Active Template Libraries (kind of like an STL for Microsoft's COM) and well as such is only for C++. You could do COM Interop with C# and get away with doing it in C# but its probably going to be too hard for what it is worth. Anyway, if you are interested in coding your own extension for IE (which is plausible if you want to have your extensions available in all major browsers) here are the official Microsoft Resources.

http://msdn.microsoft.com/en-us/library/aa753587 (v = vs.85) . aspx

至于IE8中新增的加速器,你可以看看这个。

http://msdn.microsoft.com/en-us/library/cc289775 (v = vs.85) . aspx

我同意它的文档很糟糕,api也很过时。不过,我希望这能有所帮助。

EDIT: I guess I can throw one last source of information here. I was looking through my notes of back when I was working on BHOs. And this is the article that got me started with them. It is kind of old, but has a good explanation of the ATL interfaces that you will be using when working with IE BHOs (IObjectWithSite for example). I think it is pretty well explained and helped me a lot back then. http://msdn.microsoft.com/en-us/library/bb250436.aspx I also checked the example that GregC posted. It does work with at least IE8, and it is compatible with VS 2010, so if you want to do C# you can get started there and take a look at Jon Skeet's Book. (C# in Depth 2nd edition) Chapter 13 has a good deal of information about the new features in C# 4 that you can use to make the interaction with COM nicer. (I would still recommend you doing your addin in C++)

这显然是解决了,但对于其他用户,我建议使用SpicIE框架。我在此基础上做了自己的扩展。它只支持Internet Explorer 7/8官方版本,但我在Internet Explorer 6-10(从Windows XP到Windows 8消费者预览版)上进行了测试,结果很好。 不幸的是,在最新的版本中有一些bug,所以我不得不修复它们,并发布了自己的版本: http://archive.msdn.microsoft.com/SpicIE/Thread/View.aspx?ThreadId=5251

开发c# bho是一件非常痛苦的事情。它涉及大量烦人的COM代码和p/invoke调用。

我这里有一个基本完成的c# BHO,你可以自由地使用源代码来做任何你想做的事情。我之所以说“大部分”,是因为我从未弄清楚如何在IE保护模式下保存appdata。

如果你不打算重新发明轮子,你可以试试IE的Add In Express。我已经使用该产品的VSTO的东西,它很好。此外,他们有一个有用的论坛和快速的支持。