Gre*_*ego 3 google-chrome-extension
我想通过提供URL地址来阻止要调用的URL,例如:
这不起作用,但这样的事情.
$.watch("http://www.test.com/alter.php",function(){
//It was called here
return false; //This in this scenario would block the URL to be called, it would cancel its request, it wouldn't even send the request, it would cancel before it access the web.
});
Run Code Online (Sandbox Code Playgroud)
是否可以阻止URL,以便在通过Google扩展程序在标签中调用之前不会调用或更改其请求?
提前致谢.
小智 5
您可以在阻止模式下使用chrome.webRequest的onBeforeRequest方法来取消导航.
您的清单需要声明"webRequest"和"webRequestBlocking"的权限.
然后添加一个挂钩onBeforeRequest的后台脚本,并取消该URL的导航:
chrome.extension.onBeforeRequest.addListener(function() { return {cancel: true} },
{ urls: ["http://www.test.com/alter.php"] },
["blocking"]
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
846 次 |
| 最近记录: |