谷歌插件 浏览器请求添加固定的header

总所周知中国的个人银行的网站安装了插件
  • 主要收集 ip mac 等信息 发到header
  • 只能用IE、360等插件才可以登陆

写一个谷歌插件可以修改header就可以使用心爱的谷歌

{
  "name": "Header Extensions",
  "description": "Header Level Extension",
  "version": "1.0",
  "manifest_version": 2,
  "permissions": [
    "webRequest",
    "webRequestBlocking",
    "https://*/*",
    "http://*/*"
  ],
  "background": {
    "scripts": ["background.js"]
  },
  "browser_action": {
    "default_icon": "popup.png"
  }
}
'use strict'

function addHeader (headers) {
  headers.push({ name: 'dummyHeader', value: '1' })
}

chrome.webRequest.onBeforeSendHeaders.addListener(function (details) {
    addHeader(details.requestHeaders)
    return { requestHeaders: details.requestHeaders }
  },

  { urls: ['https://*/*', 'http://*/*'] }, ['blocking', 'requestHeaders', 'extraHeaders'])

chrome.webRequest.onHeadersReceived.addListener(function (details) {
  addHeader(details.responseHeaders)
  return { responseHeaders: details.responseHeaders }
}, { urls: ['https://*/*', 'http://*/*'] }, ['blocking', 'responseHeaders', 'extraHeaders'])

posted @ 2022-06-11 14:10  vx_guanchaoguo0  阅读(1157)  评论(0编辑  收藏  举报