Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close tab after the redirect to the external application. #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function log(msg) {
}
log.enabled = false;
var enableNotifications=false;
var internalProtocolsRegexp = /^(chrome-extension|http|https|file|ftp|ws|wss):/;

var storageArea = chrome.storage.local;
//Redirects partitioned by request type, so we have to run through
Expand Down Expand Up @@ -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);}, 5000);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout is for the case when the external application opens for a first time and awaits for the confirmation from user.
Ofcourse it affects only the external application calls done by redirect from the Redirector rules. Usual external protocols openings (like magnet:, skype:, etc) will not be affected.

}

return { redirectUrl: result.redirectTo };
}
}
Expand Down Expand Up @@ -408,4 +413,4 @@ function handleStartup(){
chrome.storage.local.set({
enableNotifications: false
});
}
}