jcu*_*bic 0 iframe google-chrome-extension
谷歌浏览器可以选择禁用Flash和java,只在用户点击时运行它们,如何创建可以执行此操作的扩展程序?
您可以实现使用此功能onBeforeRequest活动的的webRequestAPI.使用type: ['sub_frame']和extraInfoSpec 创建过滤器['blocking'].然后,{cancel:true}在事件监听器中返回.
最小的例子:
chrome.webRequest.onBeforeRequest.addListener(function(details) {
// Save the data in `details` for later use
// The data must be associated with the `tabId` and `frameId`, so that it
// can be used later
if (your_method_says_block_it())
return {cancel: true};
}, {
urls: ['*://*/*'],
types: ['sub_frame']
}, ['blocking']);
Run Code Online (Sandbox Code Playgroud)
清单文件:
...
"permissions": ["webRequest", "webRequestBlocking", "*://*/*"]
...
Run Code Online (Sandbox Code Playgroud)
webRequest需要的权限启用API.webRequestBlocking需要权限以使请求处理同步的,以使函数来修改(取消)请求.*://*/*需要的权限,允许访问的主机| 归档时间: |
|
| 查看次数: |
4966 次 |
| 最近记录: |