diff options
Diffstat (limited to 'recipes/erepublik/webview.js')
-rw-r--r-- | recipes/erepublik/webview.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/recipes/erepublik/webview.js b/recipes/erepublik/webview.js new file mode 100644 index 0000000..ca55df3 --- /dev/null +++ b/recipes/erepublik/webview.js | |||
@@ -0,0 +1,41 @@ | |||
1 | 'use strict'; | ||
2 | |||
3 | var _path = _interopRequireDefault(require('path')); | ||
4 | |||
5 | function _interopRequireDefault(obj) { | ||
6 | return obj && obj.__esModule ? obj : { default: obj }; | ||
7 | } | ||
8 | |||
9 | module.exports = Ferdi => { | ||
10 | const getMessages = function getMessages() { | ||
11 | |||
12 | const elementNotify = document.getElementsByClassName('notify'); | ||
13 | const elementFeed = document.getElementsByClassName('unreadCounter ng-binding ng-scope'); | ||
14 | |||
15 | let countNotify = 0; | ||
16 | let countFeed = 0; | ||
17 | |||
18 | for (let i = 0; i < elementNotify.length; i++) { | ||
19 | let splitText = elementNotify[i].title.split(':'); | ||
20 | let badgeNumber = parseInt(splitText[1], 10); | ||
21 | if (badgeNumber) { | ||
22 | countNotify = countNotify + badgeNumber; | ||
23 | } | ||
24 | } | ||
25 | |||
26 | for (let i = 0; i < elementFeed.length; i++) { | ||
27 | let feedNumber = parseInt(elementFeed[i].textContent, 10); | ||
28 | if (feedNumber) { | ||
29 | countFeed = countFeed + feedNumber; | ||
30 | } | ||
31 | } | ||
32 | |||
33 | console.log(countNotify, countFeed); | ||
34 | Ferdi.setBadge(countNotify, countFeed); | ||
35 | }; | ||
36 | |||
37 | |||
38 | Ferdi.loop(getMessages); | ||
39 | Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
40 | Ferdi.injectCSS(_path.default.join(__dirname, 'crpk-resources/fonts.css')); | ||
41 | }; | ||