Chrome扩展无法拦截Outlook.com文件上传XMLHttpRequest请求
问题:Outlook.com文件上传请求无法被XMLHttpRequest钩子拦截
在Outlook.com中添加本地文件到邮件时,浏览器网络面板里高亮显示的HTTP上传请求完全无法被拦截,但日志中能正常捕获到其他XMLHttpRequest请求。
尝试过以下两种拦截方案,均无效果:
- 自定义XMLHttpRequest原型钩子
- 使用xhook工具拦截请求
扩展配置文件(manifest.json)
{ "name": "my extension", "version": "1.0.0", "manifest_version": 3, "action": { "default_popup": "popup.html", "default_icon": { "16": "icons/icon-16.png", "48": "icons/icon-48.png", "128": "icons/icon-128.png" } }, "content_scripts": [ { "world": "MAIN", "matches": [ "http://*/*", "https://*/*" ], "js": [ "js/inject.js" ], "run_at": "document_end", "all_frames": true } ], "permissions": [ "storage" ], "web_accessible_resources": [ { "resources": ["js/*"], "matches": ["<all_urls>"] } ] }
自定义XMLHttpRequest钩子代码(inject.js)
(function hookXMLHttpRequest() { const realOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(method, url) { console.log(method, url); realOpen.apply(this, arguments); }; })();
xhook工具尝试代码
xhook.after(function (request, response) { console.log(request.url); });
内容的提问来源于stack exchange,提问作者SantK
相关产品推荐
相关产品推荐

