Microsoft Teams web client highlight

This highlights unread messages in the Microsoft Teams Web client.

As of 2019-04-08. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name      Microsoft Teams web client highlight
// @name:ja   Microsoft Teams Webクライアントのハイライト表示
// @namespace proyuki02
// @version   4
// @license   MIT
// @grant     none
// @match     https://teams.microsoft.com/*
// @require   http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js
// @require   https://cdnjs.cloudflare.com/ajax/libs/favico.js/0.3.10/favico.min.js
// @description This highlights unread messages in the Microsoft Teams Web client.
// @description:ja This highlights unread messages in the Microsoft Teams Web client.
// ==/UserScript==

function addGlobalStyle(css) {
  var head, style;
  head = document.getElementsByTagName('head')[0];
  if (!head) { return; }
  style = document.createElement('style');
  style.type = 'text/css';
  style.innerHTML = css;
  head.appendChild(style);
}

// unread team
addGlobalStyle('.channel-list-team-header a.unread { background-color: rgba(255,182,193,0.5); }');

// unread channel
addGlobalStyle('.ts-channel-list a.ts-unread-channel { background-color: rgba(255,182,193,0.5); }');

// unread message
addGlobalStyle('.mod-unread-message-list-item > div, .mod-unread-message-list-item~.item-wrap.ts-message-list-item > div { background-color: rgba(255,182,193,0.5) !important; }');

(function(){
  var favicon = new Favico({ animation: 'slide' });
  var preCount;
  setInterval(function(){
    // notification badge
    var count = Number($(".activity-badge-container .activity-badge").text());
    if (preCount !== count) {
      preCount = count;
      favicon.badge(count);
    }

    // unread message
    $(".item-wrap.ts-message-list-item:has(.message-list-divider[data-tid='lastReadLine']:not(.ng-hide))").addClass("mod-unread-message-list-item");
  }, 1000);
})();