From 544289336114100bd060f44ec234d64991b7ee93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8C=C3=A1bera?= Date: Fri, 27 Apr 2018 16:44:16 +0200 Subject: [PATCH] Update Discord unread function Close #1423 Close #1240 Optimalization is welcome. --- app/store/ServicesList.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/store/ServicesList.js b/app/store/ServicesList.js index a9fb0405..90659bf3 100644 --- a/app/store/ServicesList.js +++ b/app/store/ServicesList.js @@ -186,9 +186,8 @@ Ext.define('Rambox.store.ServicesList', { ,url: 'https://discordapp.com/login' ,type: 'messaging' ,titleBlink: true - ,js_unread: 'function checkUnread(){var a=document.getElementsByClassName("guild unread").length,b=0,c=document.getElementsByClassName("badge");for(i=0;i0?"("+b+") ":a>0?"(•) ":"";document.title=c+originalTitle}var originalTitle=document.title;setInterval(checkUnread,3e3);' + ,js_unread: 'function getAlertCount(badges) {var alerts = 0;for(var i = 0; i 0) {var count = parseInt(badge.childNodes[0].nodeValue, 10);alerts += count.isNaN? 1: count;} else {alerts++;}}return alerts;}function checkUnread() {var direct = 0,indirect = document.querySelectorAll(\'.guilds-wrapper .unread\').length,guildDirect = document.querySelectorAll(\'.guilds-wrapper .badge\'),channelDirect = document.querySelectorAll(\'[class^="nameUnreadText-"]+div>div>div\');direct += getAlertCount(guildDirect);direct += getAlertCount(channelDirect);indirect += document.querySelectorAll(\'[class^="nameUnreadText-"]\').length;updateBadge(indirect, direct);}function updateBadge(ind, dir) { var n = dir > 0 ? "(" + dir + ") ": ind > 0? "(•) ": "";document.title = n + originalTitle;}var originalTitle = document.title;setInterval(checkUnread, 3e3);' ,note: 'To enable desktop notifications, you have to go to Options inside Discord.' - ,dont_update_unread_from_title: true ,userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36' }, {