diff options
Diffstat (limited to 'recipes/disqus/webview.js')
-rw-r--r-- | recipes/disqus/webview.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/recipes/disqus/webview.js b/recipes/disqus/webview.js new file mode 100644 index 0000000..797db5f --- /dev/null +++ b/recipes/disqus/webview.js | |||
@@ -0,0 +1,24 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | var _path = _interopRequireDefault(require("path")); | ||
4 | |||
5 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
6 | |||
7 | let getInnerInt = selector => { | ||
8 | const element = document.querySelector(selector); | ||
9 | return element && parseInt(element.innerText); | ||
10 | } | ||
11 | |||
12 | module.exports = Ferdi => { | ||
13 | const getMessages = function getMessages() { | ||
14 | let direct = ( | ||
15 | getInnerInt("header div[data-role='unread-notification-count']") || | ||
16 | getInnerInt("a.has-notifs div.notif-count") || | ||
17 | 0 | ||
18 | ); | ||
19 | |||
20 | Ferdi.setBadge(direct); | ||
21 | }; | ||
22 | |||
23 | Ferdi.loop(getMessages); | ||
24 | }; | ||