Here is a list of existing NPAPI shells for Delphi in the Mozilla browser: https://www.mozdev.org/bugs/show_bug.cgi?id=8708
The last entry (NPAPI plugin with scripting support + demonstration by Yuri Sidorov) offers exactly what is needed.
This VCL Form project can be compiled into an NPAPI compatible DLL. Manifest.json also needs to be added. After that, the plugin can be installed in Chrome, as usual.
The following HTML embeds the VCL form that is stored in the plugin:
<EMBED id="embed1" TYPE="application/x-delphi-demo-plugin" ALIGN=CENTER WIDTH=400 HEIGHT=300> <script> var embed1 = document.getElementById('embed1'); </script> <input type=button value="Show Value" onclick='alert("Value=" + embed1.value);'>
And this is how a form can change the HTML page around it:
with Plugin.GetBrowserWindowObject do GetObject('document')['bgColor'] := clRed;
PS The only fix that should be applied for modern versions of Delphi is change string
and PChar
to AnsiString
and PAnsiChar
throughout NPPlugin.pas
. Or the connection with the embedded form is broken.
source share