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

写谷歌浏览器插件的时候怎么获取到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 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用