aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/tweetdeck/webview.js
blob: 7e2a0673cd74c1db70fdd68c2332b48db110be8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module.exports = Ferdium => {
  // Tweetdeck redirect fix
  Ferdium.ipcRenderer.on('redirect-url', (event, url) => {
    window.location.assign(url);
  });

  const getMessages = () => {
    const elements = document.querySelectorAll('.msg-unread-count');
    let count = 0;
    if (elements[0]) {
      count = Ferdium.safeParseInt(elements[0].textContent);
    }

    Ferdium.setBadge(count);
  };

  Ferdium.loop(getMessages);
};