Navigation Detection in Add FF

I am migrating the Chrome extension to FF using the 'FF Addon SDK'. In the background script (main.js), I need to use the equivalent of FF ...

chrome.webNavigation.onBeforeNavigate.addListener()

and

chrome.tabs.onUpdated.addListener()

I noticed that require ("sdk / tabs") has only open, closed, trailing, etc., but has nothing to do with navigation.

I see several solutions that use Page-Mod or show a solution for the old XUL method for developing FF extensions. I am specifically looking for the FF Addon SDK solution (only).

Rate any inputs.

EDIT: I was able to find an alternative for chrome.tabs.onUpdated.addListener () using the Advanced Listener. Apparently in FF it is called onLocationChange. Still looking for an alternative to chrome.webNavigation.onBeforeNavigate.addListener ()

+4
3

, . onStateChange. onBeforeNavigation, STATE_START, STATE_IS_DOCUMENT.

var progressListener = {
    QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]),

    onLocationChange: function(aWebProgress, aRequest, aURI) {
        if (aRequest && aURI) {
            console.log('onLocationChange: ' + aURI.spec);
        }
    },

    onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
        var status = Ci.nsIWebProgressListener;

        if(aStateFlags&status.STATE_START && aStateFlags&status.STATE_IS_DOCUMENT) {
            console.log('onStateChange: ' + aRequest.QueryInterface(Ci.nsIChannel).originalURI.spec);
        }
    }
};
+1

, chrome.webNavigation.onBeforeNavigate.addListener(). . nsIWebProgressListener.onStateChange STATE_START. . : 1.) onLocationChange, URI . 2.) Httprequest. onbeginnavigate.

, .

+1

onBeforeUnload/onUnload .

0

Source: https://habr.com/ru/post/1611814/


All Articles