Skip to content

Instantly share code, notes, and snippets.

@MaxMatti
Last active January 3, 2024 09:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MaxMatti/f3679db24f6c15d69828bb1294198428 to your computer and use it in GitHub Desktop.
Save MaxMatti/f3679db24f6c15d69828bb1294198428 to your computer and use it in GitHub Desktop.
Using a secondary browser as Messenger for MS Teams only (open all links in other browser)

How to use a secondary browser as MS Teams messenger only

Linux:

  1. download files:
    • save browser.desktop as ~/.local/share/applications/browser.desktop
    • save browser.sh as /usr/local/bin/browser.sh
      • if you want to use a specific browser for your links, replace xdg-open with that browsers executable
  2. install protocols:
    • run xdg-mime default browser.desktop x-scheme-handler/browser for http
    • run xdg-mime default browser.desktop x-scheme-handler/browsers for https
  3. install Tampermonkey and external-teams-links.user.js:
    • download Tampermonkey for chrome or Firefox
    • install external-teams-links.user.js by clicking the "Raw" button above it and pressing "install" in the prompt
  4. to hide the tab bar, run your browser in app mode:
    • for Chrome: chromium --app="https://teams.microsoft.com"
      • desktop file provided below
    • for Firefox: firefox --kiosk https://teams.microsoft.com for fullscreen or the Add-On Web App Mode
    • for Edge: main menu -> "Apps" -> "Install this site as an app"

Windows:

  1. save browser.bat as C:\usr\browser.bat
  2. register URL handlers by running the two .reg-files
    • if you want to store browser.bat somewhere else, change the path in the last line of your reg files
  3. Continue with steps 3 and 4 from the instructions for Linux
@echo off
set arg1=%1
start "" %arg1:*browser=http%
[Desktop Entry]
Type=Application
Name=Browser Scheme Handler
Exec=browser.sh %u
StartupNotify=false
MimeType=x-scheme-handler/browser;
MimeType=x-scheme-handler/browsers;
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\browser]
@="URL:browser"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\browser\shell]
[HKEY_CLASSES_ROOT\browser\shell\open]
[HKEY_CLASSES_ROOT\browser\shell\open\command]
@="\"C:\\usr\\browser.bat\" \"%1\""
#!/bin/bash
xdg-open "http${1#"browser"}"
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\browsers]
@="URL:browsers"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\browsers\shell]
[HKEY_CLASSES_ROOT\browsers\shell\open]
[HKEY_CLASSES_ROOT\browsers\shell\open\command]
@="\"C:\\usr\\browser.bat\" \"%1\""
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=MS Teams
Exec=/usr/bin/chromium --app="https://teams.microsoft.com"
Icon=/home/max/.local/share/icons/teams.svg
@MaxMatti
Copy link
Author

MaxMatti commented Sep 27, 2021

Issues:

  • Pictures cannot be displayed when this is activated.
  • sent links cannot be opened by clicking

@hterik
Copy link

hterik commented Apr 24, 2023

One can fix the issue of Pictures not being displayed by adding following quick and dirty guard inside the forEach loop:
Someone can probably figure out a more robust pattern than this.

if (linkElement.href && linkElement.href.includes("teams.microsoft.com/")) {
    return
}

@MaxMatti
Copy link
Author

@hterik sorry I should have updated this earlier: You can run ms teams in chrome in app mode (see step 4) and use the chrome extension Open in Firefox to open all links that do not belong to teams in Firefox. If you use a different Browser there's also Add-Ons for that. That way you don't need Tampermonkey and you don't need steps 1 and 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment