![](/img/trans.png)
[英]how to get client public IP address using javascript or typescript
[英]how to receive the public IP address of client in onBeforeRequest
我想根据 IP 地址编写一个扩展来阻止对特定网站的请求。 我已经编写了这段代码来阻止与*://*.google.com/*
相关的所有请求。 我的问题是如何根据 IP 地址阻止onBeforeRequest
中的请求?
var urls = [
'*://*.google.com/*',
];
var types = ['main_frame', 'sub_frame']
var response = async function(d){
return true
};
chrome.webRequest.onBeforeRequest.addListener(response, { urls: urls, types: types }, ['blocking'] );
这是不可能的。 onBeforeRequest
的文档显示,这不是目前可用于扩展的信息。
然而,这是有道理的,因为在生命周期的这一点上,浏览器很可能还没有对域中服务器的 IP 地址进行任何 DNS 查询 - 如果不进行这些查询,它根本无法知道。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.