January 11, 2023

Opening external links from Teams in dedicated browser (bypass safelinks)

It seems to be a new feature now in the Microsoft Teams Client, that external (I guess non M365) links are wrapped/redirected in a  safety check whose url is  https://statics.teams.cdn.office.net/evergreen-assets/safelinks/1/atp-safelinks.html
It troubles me and I share here a workaround I have implemented in Teams Shortcuts PowerTool.

Problem Description

I have a special setup based on BrowserSelect that allows me to open specific link in a specific browser (e.g. office links in Edge) or specific Browser profile (e.g. Jira, Confluence link in a Chrome Browser specific profile mit specific extensions or customer related links with a specific customer related browser profile.)

Now, with this SafeLinks "feature" each external link is redirected to https://statics.teams.cdn.office.net/evergreen-assets/safelinks/1/atp-safelinks.html that opens in my default browser and then opens in this default browser and not the url specific one.
Especially for Jira/Confluence links in Teams, there are not opened anymore with my Jira/Confluence specific Chrome Profile. 😣

Teams Shortcuts PowerTool Solution

As workaround, I have implemented in Teams Shortcuts PowerTool (update moved to NWS PowerTool OpenLink feature) that when you now Shift+Click on a link in Teams, it will get the link behind (by opening the context menu-> Copy Link) and open the link directly, by-passing therewith the Teams SafeLink wrapping.

The code looks like this:

#If Teams_IsWinActive()

; Shift Mouse click: Open Link with default browser (ByPass SafeLink)
+LButton:: ; <--- [Teams] Open link with default browser
SavedClipboard := ClipboardAll  ; Save the entire clipboard to a variable
Clipboard := ""  ; Empty the clipboard to allow ClipWait work

; release shift key
Sendinput, {Shift up}
Click Right ; Click Right mouse button
sleep, 200 ;(wait in ms) give time for the menu to popup
SendInput {Up} {Enter}
ClipWait, 2

sUrl := Clipboard
If (sUrl = "") {
    Exit
}
Send {Esc} ; Close menu (weird that it stays open)
Run %sUrl% ; Handled by BrowserTamer

Clipboard := SavedClipboard ; Restore the original clipboard
return

Other solution

As alternative I might switch from BrowserSelect to e.g. BrowserPicker because it seems to handle this issue: Handle Teams links · Issue #24 · mortenn/BrowserPicker

See also

Browser Select (Tool recommendation)

Browser Tamer (Tool recommendation)

Handle Teams links · Issue #24 · mortenn/BrowserPicker

No comments:

Post a Comment