簡體   English   中英

如何從firefox擴展xpcom組件內部獲取啟動GET請求的頁面元素?

[英]How to get the page element initiating a GET request from inside a firefox extension xpcom component?

我有一個firefox擴展xpcom組件,它偵聽http-on-modify-request並獲取發出請求的頁面的位置:

getLocationOfOriginatingWindow: function (httpChannel) {
    try {  
        var notificationCallbacks;

        if (httpChannel.notificationCallbacks) {
            notificationCallbacks = httpChannel.notificationCallbacks;
        }
        else if (httpChannel.loadGroup && httpChannel.loadGroup.notificationCallbacks) {
            notificationCallbacks = httpChannel.loadGroup.notificationCallbacks;        
        }
        else {
            return null;
        }

        return notificationCallbacks.getInterface(Components.interfaces.nsIDOMWindow).top.location;  
    }  
    catch (e) {
        DEBUG("Exception getting Window Location: " + e + "\nChannel URI: " + httpChannel.URI.spec); 
        return null;  
    }  
},

我還想獲得發出請求的頁面元素(img,腳本等)。 有沒有一種方法可以從httpChannel中進行?

由於有許多不同的觸發請求的方式,例如CSS背景圖像翻轉,因此沒有特定的方法來告訴HTTP觀察者發出了什么請求。 您可以嘗試從內容策略一端來解決問題,我相信它可以為您提供更多信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM