aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/online-go/webview.js
blob: c2315de56e3316bf8c78dcc7790fff3062e6d0c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

const _path = _interopRequireDefault(require('path'));

module.exports = Ferdium => {
  const getMessages = () => {
    const games = document.querySelector('.TurnIndicator');
    const chat_messages = document.querySelector('.ChatIndicator .count');
    const notifications = document.querySelector(
      '.NotificationIndicator .count',
    );
    const indirect =
      Number.parseInt(notifications.textContent) +
      Number.parseInt(chat_messages.textContent);
    const direct = Number.parseInt(games.textContent);
    Ferdium.setBadge(direct, indirect);
  };
  Ferdium.loop(getMessages);

  Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
};