From 9897921a8f0340d95198a9eea597a7c368557506 Mon Sep 17 00:00:00 2001 From: Vijay Aravamudhan Date: Sun, 12 Sep 2021 18:37:25 +0530 Subject: New recipe: 'stackoverflow' (#707) --- recipes/stackoverflow/webview.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 recipes/stackoverflow/webview.js (limited to 'recipes/stackoverflow/webview.js') diff --git a/recipes/stackoverflow/webview.js b/recipes/stackoverflow/webview.js new file mode 100644 index 0000000..4d20768 --- /dev/null +++ b/recipes/stackoverflow/webview.js @@ -0,0 +1,20 @@ +const _path = _interopRequireDefault(require('path')); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +module.exports = (Ferdi) => { + const getMessages = function getMessages() { + const elements = document.querySelectorAll('.CxUIE, .unread'); + let count = 0; + for (let i = 0; i < elements.length; i += 1) { + if (elements[i].querySelectorAll('*[data-icon="muted"]').length === 0) { + count += 1; + } + } + + Ferdi.setBadge(count); + }; + + Ferdi.loop(getMessages); + Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); +}; -- cgit v1.2.3-70-g09d2