diff options
Diffstat (limited to 'uncompressed/threema/webview.js')
-rw-r--r-- | uncompressed/threema/webview.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/uncompressed/threema/webview.js b/uncompressed/threema/webview.js new file mode 100644 index 0000000..45bffee --- /dev/null +++ b/uncompressed/threema/webview.js | |||
@@ -0,0 +1,28 @@ | |||
1 | 'use strict'; | ||
2 | |||
3 | const path = require('path'); | ||
4 | |||
5 | module.exports = Franz => { | ||
6 | const getMessages = function getMessages() { | ||
7 | const elements = document.querySelectorAll('.badge.unread-count:not(.ng-hide)'); | ||
8 | let count = 0; | ||
9 | |||
10 | for (let i = 0; i < elements.length; i += 1) { | ||
11 | try { | ||
12 | count += parseInt(elements[i].innerHTML.trim(), 10); | ||
13 | } catch (e) { | ||
14 | console.error(e); | ||
15 | } | ||
16 | } | ||
17 | |||
18 | // set Franz badge | ||
19 | Franz.setBadge(count); | ||
20 | }; | ||
21 | |||
22 | // inject franz.css stylesheet | ||
23 | Franz.injectCSS(path.join(__dirname, 'service.css')); | ||
24 | |||
25 | // check for new messages every second and update Franz badge | ||
26 | Franz.loop(getMessages); | ||
27 | }; | ||
28 | //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRocmVlbWEvd2Vidmlldy5qcyJdLCJuYW1lcyI6WyJwYXRoIiwicmVxdWlyZSIsIm1vZHVsZSIsImV4cG9ydHMiLCJGcmFueiIsImdldE1lc3NhZ2VzIiwiZWxlbWVudHMiLCJkb2N1bWVudCIsInF1ZXJ5U2VsZWN0b3JBbGwiLCJjb3VudCIsImkiLCJsZW5ndGgiLCJwYXJzZUludCIsImlubmVySFRNTCIsInRyaW0iLCJlIiwiY29uc29sZSIsImVycm9yIiwic2V0QmFkZ2UiLCJpbmplY3RDU1MiLCJqb2luIiwiX19kaXJuYW1lIiwibG9vcCJdLCJtYXBwaW5ncyI6IkFBQUE7O0FBRUEsTUFBTUEsT0FBT0MsUUFBUSxNQ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hpZGUpJyk7XG4gICAgICAgIGxldCBjb3VudCA9IDA7XG5cbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBlbGVtZW50cy5sZW5ndGg7IGkgKz0gMSkge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBjb3VudCArPSBwYXJzZUludChlbGVtZW50c1tpXS5pbm5lckhUTUwudHJpbSgpLCAxMCk7XG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIHNldCBGcmFueiBiYWRnZVxuICAgICAgICBGcmFuei5zZXRCYWRnZShjb3VudCk7XG4gICAgfTtcblxuICAgIC8vIGluamVjdCBmcmFuei5jc3Mgc3R5bGVzaGVldFxuICAgIEZyYW56LmluamVjdENTUyhwYXRoLmpvaW4oX19kaXJuYW1lLCAnc2VydmljZS5jc3MnKSk7XG5cbiAgICAvLyBjaGVjayBmb3IgbmV3IG1lc3NhZ2VzIGV2ZXJ5IHNlY29uZCBhbmQgdXBkYXRlIEZyYW56IGJhZGdlXG4gICAgRnJhbnoubG9vcChnZXRNZXNzYWdlcyk7XG59O1xuIl19 \ No newline at end of file | ||