刘延林 2017-08-17 10:45 采纳率: 0%
浏览 4353
已结题

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

图片说明

  • 写回答

1条回答

  • Go 旅城通票 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.
    
    
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题