Search code examples
pythongoogle-chrome-extensionnpapicythonfirebreath

Execute Python script (that reads user data on computer) in Google Chrome extension - NPAPI


http://code.google.com/chrome/extensions/npapi.html

I have read through this, and am thoroughly confused. I have built the sample npapi .so plugin from http://www.firebreath.org/display/documentation/Building+on+Linux

Everything worked fine (plugin is installed correctly and recognized) until I went to use it in my popup.html in my unpacked extension, which threw:

<embed type="application/x-sample" id="sample">
<script>
console.log((document.getElementById("sample"))().echo("asdf"));

popup.html:18Uncaught ReferenceError: NPObject deleted

From various testing, it appears calling the constructor on the plugin object throws the error. I have no idea what's going on here.

All I really want to do is to compile a .py file using Cython into a .so or .dll, and then be able to call its methods in my extension.
Does anyone know of an easy way to do this? / Can anyone provide a simple 'hello, world' example of this working?


Solution

  • where is your extra () coming from? Most likely it should be this:

    console.log(document.getElementById("sample").echo("asdf"));
    

    What you were trying to do would probably end up trying to call the "default" method on the NPObject, which is probably nonexistent and will thus throw an exception.