Last active
February 12, 2018 08:14
-
-
Save amrtn/59203e1303846882e6efd0e52811e97d to your computer and use it in GitHub Desktop.
Highlight unread messages in Outlook Web Access (Tampermonkey script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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