Writing a Firefox Plugin for Client-Side Custom Language Analysis

I had an idea for a client language other than JavaScript, and I would like to explore the development of a Firefox plugin that will consider including this new language on a page, for example <script type = "newscript" src = "path / script.ns" / " > as if it were a language supported in the native language.The plugin will do all the parsing of the language and ideally will be able to perform every operation in the browser, html and css inside the web page as well as JavaScript.

I did a bunch of Googling and found some articles about writing basic Firefox plugins, but nothing as complicated as this.

Is it possible?

+6
firefox
source share
4 answers

@Nathan de Vries : no, in fact, the NPAPI plugins you proposed do not allow you to implement support for <script type=...> .

OP: this is not easy, but look at PyDOM and PyXPCOM - language bindings for Python. The first one does exactly what you requested - for Python, but I'm not sure about its current state. In any case, it is very likely that you need to create your own Firefox assembly to support additional script types.

+2
source share

If I understand what you want to do, you need to write a Gecko plugin. Through the plugin, you can register your own MIME type, and then manipulate Javascript and the DOM.

This means that you will need to add the <object /> or <embed /> on the page to load your plugin, but then you can search for <script type="application/x-yourtype" /> to capture the inner text of this tag script and parse it using your plugin.

As Nickolay suggested, an alternative is to use what the browser currently supports, or to create a custom browser build. Daniel Spiewak's suggestion for using a Java applet (or a Flash applet also works).

Information about you is available on the Mozilla Developer website:

+3
source share

Interesting idea. Please note that you don’t really need to write a browser-specific plugin. Some people experimented using JRuby in the Applet to execute code embedded in <script type="text/ruby"> . Such a solution may be slower at startup (due to the overhead of downloading the entire JVM instance), but in the long run it will be much more flexible (cross-browser). In addition, it’s a little easier to create a custom JVM language interpreter than trying to train it in Gecko.

+3
source share

Are you sure you want to link your pages to your own custom script? Or do you just want to write your client side code in that which is not javascript? If the latter tries MileScript , haXe , or the Google Web Toolkit

0
source share

All Articles