So there are several ways to run a home-made plugin! None of them official!
About NPAPI plugins, it seems (by a quick look at some source code) that they cannot self-activate, i.e. at page load or DOM ready, but instead function via object embedding and MIME type lists.
It could still be possible to implement some DOM-modifying functionality as NPAPI plugin which would then be activated or used via a Bookmarklet. Once the official API gets designed, coded, debugged and shipped, it should be easy to do the equivalent of such a bookmarklet. Instant (though ugly-hacked) plugins!
(What I have in mind is the basics parts of greasemonkey / stylish functionality, which could open up a big collection of javascripts and style tweaks. Those who need high-contrast, or have local news sites with horrible layout, could be very thankful.)
ActiveX dead end There is also an ActiveX shim (links to source) with class names hinting about DOM access. Dead end though, since eseidel says the ActiveX shim works on a strict whitelist, and you can't start requiring people to recompile to work with your stuff. Also you can't expect an opensource-release to whitelist you. A nyway ActiveX is hardly a good way forward. Also I don't think it would be useful for trying a quick port of some existing IE addons.
Here are some random notes about NPruntime, part of the NPAPI plugin standard. It seeems to have functionality for reading and writing "browser objects", which might mean changing the DOM?
Accessing browser objects from a plugin A plugin that wishes to access objects in the browser window that loaded the plugin can do this by getting the en/NPObject for the browsers window object, or the DOM element that loaded the plugin. This is done by using an extension to NPN_GetValue() . The extensions are two additions to the en/NPNVariables enumeration, the new enumerations areNPNVWindowNPObject and NPNVPluginElementNPObject. By calling NPN_GetValue() with either of those new enumerations will return an NPObject representing the browser object, and from there, the functions in this API can be used to get and set properties, and to call methods on those browser objects.
Could this allow for implementing a userscript plugin for Google Chrome? I'd call it GreaseMonkey Chrome :). Somebody ought to build it. Maybe Google will hold a addon contest some day, and having a NPAPI / NPruntime plugin already written could prove a winning strategy.
More on NPruntime:
testDOMAccessstatic void testDOMAccess(PluginObject *obj) { // Get plug-in's DOM element NPObject *elementObject; if (browser->getvalue(obj->npp, NPNVPluginElementNPObject, &elementObject) == NPERR_NO_ERROR) { // Get style NPVariant styleVariant; NPIdentifier styleIdentifier = browser->getstringidentifier("style"); if (browser->getproperty(obj->npp, elementObject, styleIdentifier, &styleVariant) && NPVARIANT_IS_OBJECT(styleVariant)) { // Set style.border NPIdentifier borderIdentifier = browser->getstringidentifier("border"); NPVariant borderVariant; STRINGZ_TO_NPVARIANT("3px solid red", borderVariant); browser->setproperty(obj->npp, NPVARIANT_TO_OBJECT(styleVariant), borderIdentifier, &borderVariant); browser->releasevariantvalue(&styleVariant); } browser->releaseobject(elementObject); } }
#define ID_TEST_DOM_ACCESS 3
static void testDOMAccess(PluginObject *obj) { // Get plug-in's DOM element NPObject *elementObject; if (browser->getvalue(obj->npp, NPNVPluginElementNPObject, &elementObject) == NPERR_NO_ERROR) { // Get style NPVariant styleVariant; NPIdentifier styleIdentifier = browser->getstringidentifier("style"); if (browser->getproperty(obj->npp, elementObject, styleIdentifier, &styleVariant) && NPVARIANT_IS_OBJECT(styleVariant)) { // Set style.border NPIdentifier borderIdentifier = browser->getstringidentifier("border"); NPVariant borderVariant; STRINGZ_TO_NPVARIANT("3px solid red", borderVariant); browser->setproperty(obj->npp, NPVARIANT_TO_OBJECT(styleVariant), borderIdentifier, &borderVariant); browser->releasevariantvalue(&styleVariant); } browser->releaseobject(elementObject); } }
|
|