diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index dba15539a4..8fe0f9b993 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -7106,12 +7106,13 @@ declare namespace chrome.webNavigation { transitionQualifiers: string[]; } - interface WebNavigationRequestFilter extends chrome.webRequest.RequestFilter { - /** fulfills the webRequest.RequestFilter interface even though it is under web navigation **/ + interface WebNavigationEventFilter { + /** Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event. */ + url: chrome.events.UrlFilter[]; } interface WebNavigationEvent extends chrome.events.Event<(details: T) => void> { - addListener(callback: (details: T) => void, filters?: WebNavigationRequestFilter): void; + addListener(callback: (details: T) => void, filters?: WebNavigationEventFilter): void; } interface WebNavigationFramedEvent extends WebNavigationEvent {} @@ -7221,7 +7222,7 @@ declare namespace chrome.webRequest { */ types?: string[]; /** A list of URLs or URL patterns. Requests that cannot match any of the URLs will be filtered out. */ - urls: string[] | RegExp[] | ""; + urls: string[]; /** Optional. */ windowId?: number; diff --git a/types/chrome/test/index.ts b/types/chrome/test/index.ts index 3da3f534be..ffe1ece74d 100644 --- a/types/chrome/test/index.ts +++ b/types/chrome/test/index.ts @@ -171,7 +171,7 @@ function catBlock () { ["blocking"]); } -// webNavigation.onBeforeNavigate.addListener example similar api to onBeforeRequest but without extra spec +// webNavigation.onBeforeNavigate.addListener example function beforeRedditNavigation() { chrome.webNavigation.onBeforeNavigate.addListener(function (requestDetails) { console.log("URL we want to redirect to: " + requestDetails.url); @@ -180,18 +180,10 @@ function beforeRedditNavigation() { return; } - let url = new URL(requestDetails.url); - let splitUrl = url.hostname.split('.'); - //` Note: Does not cover the XX.co.uk type edge case - let host = (splitUrl[(splitUrl.length -1) - 1]); - - if (host === null) { - return; - } else if (host === "reddit") { - alert("Were you trying to go on reddit, during working hours? :(") - return; - } - },{urls: ["http://*/*"], types: ["image"]}); + alert("Were you trying to go on reddit, during working hours? :(") + },{url: [ + {hostSuffix: ".reddit.com"} + ]}); } // for chrome.tabs.InjectDetails.frameId