aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/tiktok/webview.js
blob: d2bf2d07e697bb3b25d4a2e43b4da0dd177438f0 (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
28
29
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

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

module.exports = Ferdium => {
  const getMessages = () => {
    const selNotifications = document.querySelector(
      'div.tiktok-1b4xcc5-DivHeaderInboxContainer.e18kkhh40 > sup',
    );
    const selDM = document.querySelector(
      'div.tiktok-1ibfxbr-DivMessageIconContainer.e1nx07zo0 > sup',
    );

    const countNotifications =
      selNotifications == null
        ? 0
        : Ferdium.safeParseInt(selNotifications.outerText);
    const countDM = selDM == null ? 0 : Ferdium.safeParseInt(selDM.outerText);

    const count = countNotifications + countDM;

    Ferdium.setBadge(count);
  };
  Ferdium.loop(getMessages);

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