google-chrome-extension - chrome 扩展对 .js 没有任何作用
问题描述
我是 chrome 扩展的新手,但正在尝试设置 XSS 检测器。我有能力分别测试 GET 和 POST,所以我现在只对 GET 进行了编程。扩展加载,但是当我从已知站点进行测试时,扩展什么也不做。还设置了一个什么都没有得到的控制台日志,所以我知道扩展程序没有正确连接。任何关于为什么这不起作用的帮助将不胜感激。
我在 manifest.json 中尝试了 content_scripts,但随后在 xss_detector.js 中得到“Uncaught TypeError: Cannot read property 'onBeforeRequest' of undefined”
清单.json
{
"name": "XSS Detector",
"version": "1.0",
"manifest_version": 2,
"description": "xss detector and frame buster",
"permissions": ["tabs", "notifications", "<all_urls>", "webRequest"
"webRequestBlocking"],
"background": {
"scripts": ["xss_detector.js"],
"persistent": true
},
"browser_action": {
"default_title": "Detects and Busts!",
"default_icon": "icon.png"
}
}
xss_detector.js
chrome.webRequest.onBeforeRequest.addListener(function(details) {
const start_script_re = /.*(<div>\s*)?<script>.*<\/script>
(<\/div>\s*?.*/mi;
const end_script_re = null;
if (details.method === "GET") {
console.log("http get request");
if (decodeURI(details.url).match(start_script_re)) {
return {redirectURL:"javascript:"};
}
} else if (details.method === "POST") {
}
}, {
urls: ["<all_urls>"]
}, ["blocking", "requestBody"]);
清单.json
{
"name": "XSS Detector",
"version": "1.0",
"manifest_version": 2,
"description": "xss detector and frame buster",
"permissions": ["tabs", "notifications", "<all_urls>", "webRequest", "webRequestBlocking"],
"background": {
"scripts": ["xss_detector.js"],
"persistent": true
},
"browser_action": {
"default_title": "Detects and Busts!",
"default_icon": "icon.png"
}
}
解决方案
推荐阅读
- ios - “Over The Air”iOS 应用程序无法完整下载
- bash - 如何在服务器上用符号链接替换文件夹
- macos - 错误 ITMS-90129:“捆绑使用的捆绑名称或显示名称已被占用。”
- shell - sed 命令似乎未完成
- python - 如何使用 python mutagen 从音频文件中获取 ISRC 和 UPC 代码
- amazon-web-services - 在 Unity3d 中创建 AmazonGameLiftClient 失败
- python - 在 Python 中反转没有 Numpy 的矩阵
- wordpress - WordPress插件排队脚本不起作用
- junit5 - JUnit5 - ExpectedException.expectCause() 等效
- angular - Observables : 在新的订阅调用中取消之前的 http 请求