andy-portmen / open-in

Send URLs from one browser to another one
http://add0n.com/open-in.html
172 stars 113 forks source link

Bug: Reverse mode ON = links opened in tabs not redirected #93

Open chaoscreater opened 7 months ago

chaoscreater commented 7 months ago

When reverse mode is off, any URLs that you define in the comma separated URL list will be redirected to the target browser, regardless if you click on a link, or you paste the link into a new tab. This is great, because no matter how you open the link via whatever method, it gets redirected.

However, when reverse mode is on, any link that's not in the exception URL list should be redirected no matter how they are opened. The problem is that they only redirect when you click on the link. If you paste the link into a new tab, it'll stay open in source browser. Furthermore, not all links are redirected even when you click on them (they're not in the exception list). Some links in Outlook Office365 will stay open in the source browser, even when they are clicked on.

chaoscreater commented 7 months ago

I'm using a workaround that I've created with Autohotkey. Thought I'd share it here in case it helps someone.

It doesn't matter what "Open In XYZ" extension you're using. Just configure it to not use reverse mode and set the URL pattern to target everything, like this:

image

image

For the .exe, I've included the source code and compiled exe in the zip: Browser_Redirect.zip

The script is a bit complex, as I'm using it to do deep-linking into Teams web app chat messages etc. You can ignore that part.

The important bit is to look at how certain domains like (login.microsoftonline.com) is ignored. Even though Open In extension will redirect the URL to the browser (in my case the exe that I compiled from my AHK script), but the script isn't doing anything for login.microsoftonline.com, which means that it will still be processed on the source browser. This is important because if the source browser is primarily used for e.g. Teams web or Outlook web, then they need to login properly, instead of redirecting the login page to the target browser.

Essentially, I'm using Open In as a default blacklist mode for everything and only whitelisting certain URLs in my AHK script. By using this, all URLs, including the ones that you load into a new tab without clicking, will redirect. If you use reverse mode, then this behaviour is different and it's not what I want.

This works great for now, but ideally there should be a dedicated whitelist/blacklist mode depending on whether you have reverse mode enabled or not.