aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/circuit/webview.js
blob: ab1175f17f6487397bef46bab99cb148f5e63b26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"use strict";

module.exports = Ferdi => {
  const getMessages = function getMessages() {
    // Initialize empty vars
    var unread = 0;
    var match = [];
    // Get value of <title> tag where in case of new messages the number of messages appear
    const titleValue = document.querySelector('title').text;
    // Extract the number from the tag
    match = titleValue.match(/\d+/);
    // Set unread msgs badge
    Ferdi.setBadge(Ferdi.safeParseInt(match[0]));
  };

  const loopFunc = () => {
    getMessages();
  };

  Ferdi.loop(loopFunc);

};