小牛牛先生 2017-08-17 10:45 采纳率: 0%
浏览 4365
已结题

写谷歌浏览器插件的时候怎么获取到newwork中的请求的response信息

图片说明

  • 写回答

1条回答 默认 最新

  • 斯洛文尼亚旅游 2017-08-18 05:13
    关注

    自己用ajax获取内容就行了,配置好manifest允许跨域请求的页面,结合webRequet得到请求的url地址,判断是你要获取内容的再发送ajax
    需要翻墙
    https://developer.chrome.com/extensions/webRequest#event-onCompleted

           {
            "name": "My extension",
            ...
            "permissions": [
              "webRequest",
              "*://*.google.com/"
            ],
            ...
          }
    
     onBeforeRequest
    
    Fired when a request is about to occur.
    
    addListener
    chrome.webRequest.onBeforeRequest.addListener(function callback)
    Parameters
    function    callback    
    The callback parameter should be a function that looks like this:
    
    function(object details) {...};
    object  details 
    string  requestId   
    The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
    
    string  url 
    string  method  
    Standard HTTP method.
    
    integer frameId 
    The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (type is main_frame or sub_frame), frameId indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab.
    
    integer parentFrameId   
    ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
    
    object  (optional) requestBody  
    Since Chrome 23.
    
    Contains the HTTP request body data. Only provided if extraInfoSpec contains 'requestBody'.
    
    string  (optional) error    
    Errors when obtaining request body data.
    
    object  (optional) formData 
    If the request method is POST and the body is a sequence of key-value pairs encoded in UTF8, encoded as either multipart/form-data, or application/x-www-form-urlencoded, this dictionary is present and for each key contains the list of all values for that key. If the data is of another media type, or if it is malformed, the dictionary is not present. An example value of this dictionary is {'key': ['value1', 'value2']}.
    
    array of UploadData (optional) raw  
    If the request method is PUT or POST, and the body is not already parsed in formData, then the unparsed request body elements are contained in this array.
    
    integer tabId   
    The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
    
    ResourceType    type    
    How the requested resource will be used.
    
    double  timeStamp   
    The time when this signal is triggered, in milliseconds since the epoch.
    
    
    
    评论

报告相同问题?