aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/proton-mail/webview.js
blob: 395b77942f41ae2b9765c537af7e3f67511f97c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module.exports = Ferdi => {
  const getMessages = () => {
    const element = document.querySelector('.navigationItem-counter');
    if (!element) {
      return;
    }
    const text = element.textContent;
    if (text) {
      // eslint-disable-next-line unicorn/prefer-string-slice
      const count = Ferdi.safeParseInt(text.substring(1, text.length - 1));
      Ferdi.setBadge(count);
    }
  };

  Ferdi.loop(getMessages);
};