From 84bf3cd095595a00e6f67064606246a2f28d87ee Mon Sep 17 00:00:00 2001 From: motemen Date: Tue, 21 Oct 2014 10:41:19 +0900 Subject: [PATCH] fixed chrome.webRequest.RequestFilter.types --- chrome/chrome-tests.ts | 23 ++++++++++++++++++++++- chrome/chrome.d.ts | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/chrome/chrome-tests.ts b/chrome/chrome-tests.ts index 1d041a79b5..8d27a9d554 100644 --- a/chrome/chrome-tests.ts +++ b/chrome/chrome-tests.ts @@ -152,4 +152,25 @@ function printPage() { var action_url = "javascript:window.print();"; chrome.tabs.update(tab.id, { url: action_url }); }); -} \ No newline at end of file +} + +// 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"]); +} diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index 5e7ef4eb53..da42f687a3 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -2248,7 +2248,7 @@ declare module chrome.webRequest { interface RequestFilter { tabId?: number; - types?: string; + types?: string[]; urls: string[]; windowId?: number; }