From a5e99aa01d25c0989dd27b1a0b33f8ba5cd4f15b Mon Sep 17 00:00:00 2001 From: Ramiro Saenz Date: Tue, 2 Aug 2016 15:07:17 -0300 Subject: [PATCH] Updated Add a Custom Service (markdown) --- Add-a-Custom-Service.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Add-a-Custom-Service.md b/Add-a-Custom-Service.md index f548e94..5744377 100644 --- a/Add-a-Custom-Service.md +++ b/Add-a-Custom-Service.md @@ -5,11 +5,16 @@ 3. Enter a name of the Service to display in the tab. 4. Enter a URL for the service. Be sure the URL, when you aren't logged, shows a login form or if you are logged, shows the app. 5. Enter a URL for the Logo of the service to display it in the tab. -6. In Advanced option, there is an _Unread Code_ field. This field you will use it if the service you are adding is not notifying an activity (new messages, new emails, etc) throw the title of the page (Ex. "(2) Facebook Messenger"). The number 2 means there are 2 messages unread. This code will be injected to the service page to run it (must return an Integer) and it will be embeded into this code: +6. In Advanced option, there is an _Unread Code_ field. This field you will use it if the service you are adding is not notifying an activity (new messages, new emails, etc) throw the title of the page (Ex. "(2) Facebook Messenger"). The number 2 means there are 2 messages unread. + +Here is an example code that you can start with: ```javascript function checkUnread() { - updateBadge(_YOUR_CODE_WILL_BE_PLACED_HERE_); + var e = document.getElementsByClassName("unread_countValue"); + var t = 0; + for( i = 0; i < e.length; i++ ) t += parseInt(e[i].innerHTML.trim()); + updateBadge(t); } function updateBadge(e) { @@ -19,10 +24,6 @@ var originalTitle = document.title; setInterval(checkUnread, 3000); ``` -Here is an example code that you can start with: - -```javascript -(function(){var e=document.getElementsByClassName("unread_countValue"),t=0;for(i=0;i