Connect a Firefox extension using a C # application

I need to make such an event so that every time the user loads a new page and closes firefox, I need him to call a method in my C # application that takes care of maintaining the user model. I know for sure that I need to create some type of firefox extension, where I use javascript to check for such an event. However, I do not know how I am going to integrate my C # application with the firefox extension. Can someone provide me some recommendations?

+5
source share
2 answers

I will help you with issues that are familiar to me (Javascript-based add-ons), and suggest some suggestions for other parts. Nothing happens here!

Additions

Firefox add-ons easily provide the tools you need to detect page loading and open / close firefox.

To detect page loading , you can register a listener in the DOMContentLoaded event in a window.

window.addEventListener("DOMContentLoaded", function(event){
    var url = event.originalTarget.location.href;
    alert("Oh yeah, a document is loading: " + url);
}, false);

Alternatively, you can register nsIWebProgressListener to listen for location changes . This is probably closer to what you want, as it DOMContentLoadedalso runs for iframes.

var listener = {
    //unimplemented methods (just give functions which do nothing)
    onLocationChange: function(aWebProgress, aRequest, aLocation){
        var url = aLocation.asciiSpec;
        alert("Oh yeah, a the location changed: " + url);
    }
};
gBrowser.addTabsProgressListener(listener);

firefox open/close, , Firefox . firefox, . , , firefox windows , :

window.addEventListener("load", function(event){ 
    alert("Looks like you just opened up a new window");
}, false);

window.addEventListener("unload", function(event){
    alert("Awh, you closed a window");
}, false);

, , / firefox . , Javascript Modules. Javascript . , . .

var EXPORTED_SYMBOLS = ["windowOpened", "windowClosed"];
var windowsOpened = 0;
function windowOpened(){
    if( windowsOpened === 0) {
        alert("The first window has been opened!");
    }
    windowsOpened++;
}

function windowClosed(){
    windowsOpened++;
    if( windowsOpened === 0) {
        alert("The last window has been closed!");
    }
}

, 2 load unload.

, , Firefox. , Mozilla Addon Builder, . ( Javascript) ff-overlay.js( ).

#

#. , , SO .

, COM- - Windows. , Binary Component . , , , javascript. Mozilla Visual Studio.

, SDK, javascript. , , , sqlite .. SO > , . , .

  • Sqlite

(1), , . (2), IPC, . (3) , ( , Distributed Systems ).

TL;DR

. Addon Builder, FF , .

# SO-. sqlite , .

+3

All Articles