Merge pull request #3003 from motemen/chrome-webrequest-requestfilter-types

Fix chrome.webRequest.RequestFilter.types
This commit is contained in:
Masahiro Wakame 2014-10-21 11:45:06 +09:00
commit d5713b68db
2 changed files with 23 additions and 2 deletions

View File

@ -152,4 +152,25 @@ function printPage() {
var action_url = "javascript:window.print();";
chrome.tabs.update(tab.id, { url: action_url });
});
}
}
// https://developer.chrome.com/extensions/examples/extensions/catblock/background.js
function catBlock () {
var loldogs: string[];
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
console.log("Cat intercepted: " + info.url);
// Redirect the lolcal request to a random loldog URL.
var i = Math.round(Math.random() * loldogs.length);
return {redirectUrl: loldogs[i]};
},
// filters
{
urls: [
"https://i.chzbgr.com/*"
],
types: ["image"]
},
// extraInfoSpec
["blocking"]);
}

2
chrome/chrome.d.ts vendored
View File

@ -2248,7 +2248,7 @@ declare module chrome.webRequest {
interface RequestFilter {
tabId?: number;
types?: string;
types?: string[];
urls: string[];
windowId?: number;
}