From ead37425f085d3ef425bf61dd99619894cec037a Mon Sep 17 00:00:00 2001 From: Michael Khaimov Date: Mon, 6 May 2019 20:17:32 +0300 Subject: [PATCH] Close tab after the redirect to the external application. --- js/background.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/background.js b/js/background.js index 00ba31b..bb2d23d 100644 --- a/js/background.js +++ b/js/background.js @@ -8,6 +8,7 @@ function log(msg) { } log.enabled = false; var enableNotifications=false; +var internalProtocolsRegexp=/^(chrome|chrome-extension|data|http|https|file|ftp|mailto|resource|ws|wss):/; var storageArea = chrome.storage.local; //Redirects partitioned by request type, so we have to run through @@ -98,6 +99,10 @@ function checkRedirects(details) { } ignoreNextRequest[result.redirectTo] = new Date().getTime(); + if (result.redirectTo.match(internalProtocolsRegexp) == null) { + window.setTimeout(function(){chrome.tabs.remove(details.tabId);}, 2000); + } + return { redirectUrl: result.redirectTo }; } } @@ -408,4 +413,4 @@ function handleStartup(){ chrome.storage.local.set({ enableNotifications: false }); -} \ No newline at end of file +}