chrome扩展无法通过onHeadersReceived获取标头

时间:2016-10-29 18:16:46

标签: google-chrome-extension

我正在尝试阅读带有Chrome扩展程序的网站的响应标题,但我无法检索扩展程序中的标题。我想有些东西阻止后台脚本访问标题,我很想知道是什么,以及是否可以禁用它。

manifest.json

"permissions": [
  "webRequest",
  "webRequestBlocking",
  "*://*/"
],
"background": {
  "scripts": ["background.js"],
  "persistent": true
},

background.js

function requestProcessor(details) {
    alert(details.url+' => '+JSON.stringify(details.responseHeaders));
    return {responseHeaders: details.responseHeaders};
}
chrome.webRequest.onHeadersReceived.addListener(requestProcessor, {
    urls: ["*://*/*"],
    types: ["main_frame", "sub_frame"]
}, ["blocking", "responseHeaders"]);
我使用开发工具

获得的网站的响应标题
cache-control:no-cache
content-encoding:gzip
content-security-policy: ...
content-type:text/html; charset=UTF-8
date:Sun, 23 Oct 2016 21:09:52 GMT
last-modified:Tue, 18 Oct 2016 21:56:14 GMT
pragma:no-cache
server:...
status:200
strict-transport-security:max-age=15552000; includeSubDomains; preload
vary:Accept-Encoding, User-Agent, Accept-Language
via:HTTP/1.1 169.111.111.111:443 (/ 66.111.111.111)
x-connected-to:169.111.111.111
x-content-type-options:nosniff
x-fb-ip-type:allowed
x-frame-options:DENY

0 个答案:

没有答案