1 2 3 4 5 6 7 8 9 10 11 12 13
module.exports = Ferdi => { const getMessages = () => { const unreadSpan = document.querySelector( 'span.flag-count.message-count.unread-count', ); let directCount = 0; if (unreadSpan) { directCount = Ferdi.safeParseInt(unreadSpan.textContent); } Ferdi.setBadge(directCount); }; Ferdi.loop(getMessages); };