Skip to content

Instantly share code, notes, and snippets.

@fallaciousreasoning
Last active November 18, 2019 23:12
Show Gist options
  • Save fallaciousreasoning/0390208ba5debdcde06094ae19ed5f8c to your computer and use it in GitHub Desktop.
Save fallaciousreasoning/0390208ba5debdcde06094ae19ed5f8c to your computer and use it in GitHub Desktop.
A ViolentMonkey/TamperMonkey/GreaseMonkey script for setting unread counts on Outlook.com
// ==UserScript==
// @name Outlook Unread Badge
// @namespace Violentmonkey Scripts
// @match https://outlook.live.com/mail/*
// @grant none
// ==/UserScript==
const getUnreadCount = () => {
return document.querySelectorAll(`div[aria-label~='Unread']`).length;
}
const updateUnreadCount = () => {
const Badge = navigator.setAppBadge || navigator.setExperimentalAppBadge;
if (!Badge)
return;
const unreadCount = getUnreadCount();
Badge.call(navigator, unreadCount);
}
const poll = (func, regularity) => {
func();
setTimeout(() => {
poll(func, regularity);
}, regularity)
};
poll(updateUnreadCount, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment