Skip to content

Instantly share code, notes, and snippets.

@amrtn
Last active February 12, 2018 08:14
Show Gist options
  • Save amrtn/59203e1303846882e6efd0e52811e97d to your computer and use it in GitHub Desktop.
Save amrtn/59203e1303846882e6efd0e52811e97d to your computer and use it in GitHub Desktop.
Highlight unread messages in Outlook Web Access (Tampermonkey script)
// ==UserScript==
// @name OWA improver
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://correoweb.mapama.es/*
// @grant GM_addStyle
// ==/UserScript==
(function () {
'use strict';
GM_addStyle(`
div.has-unread-message {
font-weight: bold;
background-color: #d0c7ff;
}
` );
let observer = new MutationObserver(mutationChecker);
observer.observe(document.body, { attributes: true, childList: true });
function mutationChecker(mutationList) {
for (const mutation of mutationList) {
removeUnreadTags();
addUnreadTags();
}
}
function addUnreadTags() {
const unreadMessagesSelector = '[tempid^="id=emailslistviewpanel"] .ms-font-weight-semibold.ms-font-color-themePrimary';
const unreadNodes = document.querySelectorAll(unreadMessagesSelector);
Array.from(unreadNodes).forEach(el => el.parentElement.parentElement.classList.add('has-unread-message'));
}
function removeUnreadTags() {
Array.from(document.getElementsByClassName('has-unread-message')).forEach(el => el.classList.remove('has-unread-message'));
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment