aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/tiktok/webview.js
blob: c3af44cdf21eb5cf8359bb9299e6f2948537cb7f (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-1deszxq-DivHeaderInboxContainer.e18kkhh40 > sup',
    );
    const selDM = document.querySelector(
      'div.tiktok-9j9jz0-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'));
};