aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/tiktok/webview.js
blob: 6f78019f217d9850c7bca3999cb6b2c6a7de1acc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const _path = _interopRequireDefault(require('path'));

function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

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) ? Ferdium.safeParseInt(selNotifications.outerText) : 0;
    const countDM = (selDM != null) ? Ferdium.safeParseInt(selDM.outerText) : 0;

    const count = countNotifications + countDM;

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

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