开发者

I want to make browser add-ons/extentions, which programming language do i need to learn?

开发者 https://www.devze.com 2022-12-14 19:53 出处:网络
Which programming languages do i need to learn to make browser add-ons/extentions fo开发者_Python百科r all the browsers out there?

Which programming languages do i need to learn to make browser add-ons/extentions fo开发者_Python百科r all the browsers out there?

I have been told its Javascript? Thank you in advance.


Actually I disagree with the other answers somewhat because, in my experience, choice of programming language is not a constraint in and of itself when writing an extension for Mozilla or IE.

IE uses COM so you are just as able to use C or C++ as you are to use .NET languages.

Likewise, Mozilla uses XPCOM, so what you actually need is an XPCOM binding rather than any specific language.

I've written extensions for both of these browsers in C++. I've got no experience of writing extensions for other browsers.


I once said something along these lines about IE:

IE itself is written in C++ and makes extensive use of COM. The extensibility model is COM based as well. In my experience, you have the following trade-offs to choose amongst:

  1. Pure C++ and COM. You build everything from the ground up, including class factories, COM object registration, interface implementations, etc. You spend an extra day or so implementing IUnknown, IClassFactory, IObjectWithSite, etc, and you get the pain of figuring out how IConnectionPoint and IConnectionPointContainer work. However, now you know how everything works, and your project is much easier to debug and maintain as it grows, and you grow as a person. And I promise to give you helpful answers if you do it this way.
  2. Use ATL/MFC and write it in C++. You get started a lot quicker because all the COM glue and basic interfaces are implemented for you. The down side is you pull your hair out debugging templated goo in header files you didn't write when things go wrong. You experience crashes that you can't explain.
  3. You write it in C# and have all sorts of GAC, runtime version and other issues. Only with v4 of the runtime can you host different versions side-by-side. You get less help from forums since IE extensions really should be native and not managed. You get to write a bunch of interop (or at least whatever pinvoke.net doesn't already have) and good luck debugging when that goes wrong. Further more, IE see all managed extensions as being mscorewhatever, not YourExtension.dll, so users are frequently confused in the manage/add-ons UI. And Microsoft explicitly says not to write managed Shell extensions, so you have to make sure only iexplore.exe loads your extension, and not explorer.exe. And if you want it to run on other platforms, you're going to have a lot of trouble porting it.

These are just, like, my opinions, though, so feel free to get second ones.

As far as Firefox goes, you can write a lot of extensions without ever using XPCOM. Their core extensibility model is XUL + JavaScript, which is all markup and script. 99% of all extensions can be implemented this way. However, there are somethings you just can't do in their framework, e.g. Cooliris, so you have to resort to XPCOM to call native code (or NPAPI).

Chrome extensions are Javascript and markup as well, but if you want to write plug-ins for Chrome that do any sort of native stuff you have to use NPAPI, which is a C API.

So, in summary, you can cover a lot of ground with Javascript, XML and HTML, but you miss IE and are limited in what you can do. If you want to go all the way, you need to learn C++ (and understand the subtle differences between C++ and C for NPAPI). I don't recommend messing around with C#-based browser plug-ins, despite the numerous examples out there on how to write toolbars for IE in C#.


For Mozilla-based browsers, you'll want to primary look at Javascript (and the other technologies listed here).

For Internet Explorer, any of the .NET languages are typically what's used for creating IE browser plugins.


There isn't a single answer for all browsers, but for Mozilla browsers like FireFox, you're primarily talking JavaScript. For IE, naturally, it's going to be .NET languages. For other browsers it will depend, but often some JavaScript with perhaps a little of the language that browser is programmed in.

For Mozilla browsers, the Extensions section of the Mozilla Development Center is a great place to start.

0

精彩评论

暂无评论...
验证码 换一张
取 消