aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/plurk/webview.js
blob: da52aecc3e3b4a592138dae254b4f4ec51f7ba67 (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
24
25
26
27
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

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

module.exports = Ferdium => {
  const getMessages = () => {
    let direct = 0;

    const np = document.querySelector('#noti_np_count');
    const re = document.querySelector('#noti_re_count');

    if (np) {
      direct += Ferdium.safeParseInt(np.textContent);
    }
    if (re) {
      direct += Ferdium.safeParseInt(re.textContent);
    }

    Ferdium.setBadge(direct);
  };

  Ferdium.loop(getMessages, 10_000);

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