문제

I have coded a browser helper object in C# for IE, and would like to wrap up that code to implement a chrome/firefox extension. My research led me to Firebreath. I am now loading a content_script file which will fire an onSubmit event and send a message to backgound.htm,js files which handles my firebreath plugin. However, sure enough, m_host now points to the background htm file rather than the original website (from which the user pressed submit button). I tried replacing the html code form the native plugin, but it is not working..

test setup:

content_script:

document.addEventListener('DOMContentLoaded', function () {
alert(document.forms.length);
for (var i = 0; i < document.forms.length; i++) {
    document.forms[i].addEventListener("submit", function () {
        var documentHTML = "<html>" + document.documentElement.innerHTML + "</html>";
        chrome.runtime.sendMessage({ inputElement: documentHTML }, function (response) {        }); }); } });

background.js:

chrome.runtime.onMessage.addListener(
   function (request, sender, sendResponse) {
     document.getElementById('plugin0').sethtml(request.inputElement); });

firebreath code:

void coolnewtestpluginAPI::setInnerHTML(const FB::variant& innerHTML)
{
    m_host->getDOMDocument()->setInnerHTML(innerHTML.convert_cast<std::string>());
}

The native plugin is being called, and I can debug through it. "setInnerHTML()" returns successfully without any errors, but the html code is not being updated, and refers to the original background.htm file. Any ideas?

PS: I'm not that fluent in javascript, so I'd rather offload as much as possible to c# / c++

도움이 되었습니까?

해결책

The only way to put an NPAPI/FireBreath plugin into the actual page is to inject the object tag into that page using javascript from the extension. Otherwise the plugin will know nothing about that page.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top