将 Firefox 扩展移植到 BHO(浏览器帮助对象,又名 IE 扩展)

发布于 2024-10-04 08:28:07 字数 253 浏览 0 评论 0原文

我有一个 Firefox 扩展,我想将其移植到 IE,我不想再次编码。

有什么可以帮助我的吗?它可以以非常不同的方式出现:

  • 一个可以呈现 Firefox 扩展的 IE BHO,其中 IE 功能映射到 FF 扩展调用的功能。
  • 一个生成器,它采用 FF 扩展并生成 BHO(用 C、C# 等,无论它想要什么)。

编辑:可能没有这样的事情。我将保持问题开放......

编辑:问题到今天为止无关紧要

I have a Firefox extension that I would like to port to IE, I don't want to code it again.

Is there something that can help me? It could come in very different ways:

  • An IE BHO that can render a firefox extension, with IE fonctions mapped to the ones the FF extension calls.
  • A generator that takes a FF extension and generates a BHO (in C,C#,etc. whatever it wants).

EDIT: There may be no such thing. I'll keep the question open...

EDIT: question is irrelevant as of today

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清泪尽 2024-10-11 08:28:07

没有简单的出路。模型有很大不同。尽可能抽象你的核心代码,并为每个浏览器编写一次胶水。

There is no easy way out. The models are very different. Abstract your core code to the extent that you can, and write the glue once for each browser.

月依秋水 2024-10-11 08:28:07

我们使用一个代码库以及我们自己的 IE 和 FF 函数之间的映射所遇到的最大问题是接口略有不同或存在其他错误,因此您无法在浏览器之间使用一致的方法。

您将拥有一个更重的帮助程序库来使这两个接口与您的使用保持一致,或者重新编写一些解决方法。

由于我们首先有一个 IE BHO,因此我们有类似以下的内容来将 IE 内容映射到 FF,但根据您使用的内容,您可能会发现您需要从最详细到最不详细的两种方式的映射。这里有一些快速的想法给你

// Normally if you where just doing IE or FF you would use one technique for getting a different interface
// as we are mixing the code, we have macros which allows you to use a combination of code
// eg.  for IE  CComQIPtr<IHTMLDocument2> doc( disp );
// eg.  for FF  nsCOMPtr<IHTMLDocument2> doc( do_QueryInterface(disp) );
// combined in code will be CComQIPtr<IHTMLDocument2> doc( do_QueryInterface(disp) );
// FF strips off the QI,  IE strips out the do_QueryInterface.
#ifdef MOZILLA
#define CComPtr                     nsCOMPtr
#define CComQIPtr                   nsCOMPtr

#define IWebBrowser2                nsIDOMWindow
#define IHTMLWindow2                nsIBrowserDOMWindow
#define IHTMLDocument2              nsIDOMHTMLDocument

#define get_Document            GetDocument
#define get_type                    GetType
#else
// Pointer handling for nsCOMPtr vs CComPtr/CComQIPtr
#define getter_AddRefs(x)       (&(x).p)        
#define do_QueryInterface(x)        (x)
#endif

祝你好运!

The biggest problem we have with one codebase and our own mapping between IE and FF functions is where the interfaces differ slightly or are otherwise buggy so you cannot use a consitent approach across browsers.

You will either have a heavier helper library to make the 2 interfaces consitent for your usage, or be re writing some of the workarounds.

As we had an IE BHO first we have things like the following to map the IE stuff to FF, but depending on what you use you may find you need mappings both ways from the most detailed to the least. Here are some quick ideas for you

// Normally if you where just doing IE or FF you would use one technique for getting a different interface
// as we are mixing the code, we have macros which allows you to use a combination of code
// eg.  for IE  CComQIPtr<IHTMLDocument2> doc( disp );
// eg.  for FF  nsCOMPtr<IHTMLDocument2> doc( do_QueryInterface(disp) );
// combined in code will be CComQIPtr<IHTMLDocument2> doc( do_QueryInterface(disp) );
// FF strips off the QI,  IE strips out the do_QueryInterface.
#ifdef MOZILLA
#define CComPtr                     nsCOMPtr
#define CComQIPtr                   nsCOMPtr

#define IWebBrowser2                nsIDOMWindow
#define IHTMLWindow2                nsIBrowserDOMWindow
#define IHTMLDocument2              nsIDOMHTMLDocument

#define get_Document            GetDocument
#define get_type                    GetType
#else
// Pointer handling for nsCOMPtr vs CComPtr/CComQIPtr
#define getter_AddRefs(x)       (&(x).p)        
#define do_QueryInterface(x)        (x)
#endif

Good Luck!

赤濁 2024-10-11 08:28:07

根据注入 js 的插件(并将 ie 绑定到您在 ff 中使用的方法)更加可移植,

有些网站/软件可以使用可编译为 ie 和 ff 的单个代码

depending on the plugin injecting js(and bind ie to the methodes you use in ff) is a lot more portable

there are sites/software that can use single code that compiles both to ie and ff

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文