aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/circuit/webview.js
blob: 8cd2e2f17e1493817613f766029b0c2da071f37d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
module.exports = Ferdi => {
  const getMessages = function getMessages() {
    // Get value of <title> tag where in case of new messages the number of messages appear
    const titleValue = document.querySelector('title').text;
    const match = titleValue.match(/\d+/);
    const unread = match != null && match.length > 0 ? match[0] : 0;

    Ferdi.setBadge(Ferdi.safeParseInt(unread));
  };

  Ferdi.loop(getMessages);
};