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

module.exports = Ferdi => {
  const getMessages = function getMessages() {
    // Initialize empty vars
    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);

};