Add a Custom Service

Ramiro Saenz edited this page Aug 5, 2016 · 9 revisions

How to add a Custom Service

  1. Be sure to be in the first tab of the app called Rambox Tab.
  2. At the end of the list of services, select _Custom Service or just search for "custom" in the search field.
  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.

Here is an example code that you can start with:

function checkUnread() {
    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) {
    e >= 1 ? document.title = "(" + e + ") " + originalTitle : document.title = originalTitle
}
var originalTitle = document.title;
setInterval(checkUnread, 3000);

Also, you can add another code to do whatever you want. See here.

Once you finish writing and testing your code, it will be a great practice to minify it before pasting it into the Dialog Box into Rambox. To minify it, you can use JSCompress.