Last active
November 18, 2019 23:12
-
-
Save fallaciousreasoning/0390208ba5debdcde06094ae19ed5f8c to your computer and use it in GitHub Desktop.
A ViolentMonkey/TamperMonkey/GreaseMonkey script for setting unread counts on Outlook.com
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 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