I am very interested in writing the source code example code of the browser plug-in using the npapi: The plug-in of chrome and Firefox. Almost all of them are about methods and APIs, it's really hard to find a simple code instance that can run! But finally fortunately, finally find an example (http://geeklu.com/2010/10/getting-started-with-npapi-plugin/comment-page-1 ). unfortunately, this example cannot work properly on my Linux machine. so I wrote a new example based on this example, and I also wrote a chrome extension for demonstration. expansion of npapi and chrome: npapi: [1] http://colonelpanic.net/2009/05/building-a-firefox-plugin-part-two/4242] license http://blogold.chinaunix.net/u3/94039/showart_2004756.htm L [4] https://developer.mozilla.org/en/plugins%5] how to use chrome extensions: http://code.google.com/chrome/extensions/npapi.html%6] How to Write chrome extensions: Compile -Some functions in headers/plugin_exec.c: the format of the char * np_getmimedescription () return string must be: "text/html: htm, HTML: HTML document; application/X-texinfo: tex, Texi, texinfo: texinfo document; "For details, see [3] nperrornp_getvalue (void * future, nppvariable variable, void * value). You must process the case where variable is nppvpluginneedsxembed, otherwise, chrome will not enable the plug-in (Firefox is still normal). Demo method: $ CP libplugin_exec.so ~ /. Mozilla/plugins $ Firefox wkt.html $ Google-chrome wkt.html ### enter a command on the webpage (you must run it before you can exit the window, for example, gnome-terminal, otherwise the effect will not be visible ), click "run.
Demonstration Method of chrome Extension: the extension is loaded under the chrome_extension directory (see step 6 of [6] for the loading method ), then, a menu item "save link to/tmp/Link" appears in the right-click menu of each link on the page. log, click this menu item, and the link URL will be saved to/tmp/link. log
Finally, I would like to thank my roommate Lei guodong for his active help. The source code for this example is http://u.115.com/file/f23aeb448f. This example is only compiled/tested In Debian SID/ubuntu10.10.