desafelinksifier

home | talks | bugs | projects

the following are javascript bookmarklets for the web versions of outlook and teams, which disable Microsoft SafeLinks functionality.

  1. bookmark anything, for example this page.
  2. right click the bookmark > click edit.
  3. change the title to whatever and the URL to one of the following.

outlook

javascript:(()=>{document.querySelectorAll('a[originalsrc]').forEach(l=>{let u=l.getAttribute('originalsrc');l.href=u;l.title=u;if(/safelinks.protection/i.test(l.textContent)){l.textContent=u}})})()

when you have an email open, click the bookmark, and it will change all SafeLinks in view to their original URLs.

teams

javascript:(()=>{if(window.__dsl)return;window.__dsl=1;window.addEventListener('click',e=>{const l=e.target.closest?.('a[data-testid="atp-safelink"]');if(!l)return;e.stopImmediatePropagation();e.preventDefault();window.open(l.href,'_blank','noopener,noreferrer')},true)})()

when you have teams open, click the bookmark, and SafeLinks will be disabled until your page is reloaded.

the original code indented properly

outlook:

javascript:(() => {
  document.querySelectorAll('a[originalsrc]').forEach(l => {
    let u = l.getAttribute('originalsrc');
    l.href = u;
    l.title = u;
    if (/safelinks.protection/i.test(l.textContent)) {
      l.textContent = u;
    }
  });
})()

this just replaces the link with the originalsrc attribute which already stores the original URL. click it to remove any SafeLinks on the page.

teams:

javascript:(() => {
  if (window.__dsl) return;
  window.__dsl = 1;
  window.addEventListener('click', e => {
    const l = e.target.closest?.('a[data-testid="atp-safelink"]');
    if (!l) return;
    e.stopImmediatePropagation();
    e.preventDefault();
    window.open(l.href, '_blank', 'noopener,noreferrer');
  }, true);
})()

teams is a bit different as it has a click handler for URLs, this bookmarklet catches the click before teams does. works until page is refreshed.

thanks eve for suggesting an improvement

why?

there are SafeLinks bypasses already, you can even just use simple link shorteners to evade SafeLinks... sometimes SafeLinks just crashes too and takes up like 30 seconds every time you go to click on a URL. this is intended to be used as a timesaving measure and you should be careful of every link you click regardless of whether or not you use this tool.