aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/nextcloud-calendar/webview.js
blob: 3ff240f7ba2427e59ad5f8f6f960d0273089558d (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
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

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

module.exports = Ferdium => {
  // With `// Legacy ` are marked those selectors that were working for some
  // Nextcloud version before 27 (24 or 25).
  const notificationElement = '.notification-wrapper .notification';
  const getMessages = () => {
    Ferdium.setBadge(
      Ferdium.safeParseInt(
        document.querySelectorAll(
          `.notifications ${notificationElement}[object_type="dav"], ` + // Legacy
            `.notification-container ${notificationElement}[data-app="dav"]`, // Nextcloud 27
        )?.length,
      ),
    );
  };
  Ferdium.loop(getMessages);
  Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
};