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/icon.svg | 1 + recipes/stackoverflow/index.js | 1 + recipes/stackoverflow/package.json | 11 +++++++++++ recipes/stackoverflow/service.css | 5 +++++ recipes/stackoverflow/webview.js | 20 ++++++++++++++++++++ 5 files changed, 38 insertions(+) create mode 100644 recipes/stackoverflow/icon.svg create mode 100644 recipes/stackoverflow/index.js create mode 100644 recipes/stackoverflow/package.json create mode 100644 recipes/stackoverflow/service.css create mode 100644 recipes/stackoverflow/webview.js (limited to 'recipes/stackoverflow') diff --git a/recipes/stackoverflow/icon.svg b/recipes/stackoverflow/icon.svg new file mode 100644 index 0000000..5298d4c --- /dev/null +++ b/recipes/stackoverflow/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/recipes/stackoverflow/index.js b/recipes/stackoverflow/index.js new file mode 100644 index 0000000..23607bd --- /dev/null +++ b/recipes/stackoverflow/index.js @@ -0,0 +1 @@ +module.exports = Ferdi => Ferdi; diff --git a/recipes/stackoverflow/package.json b/recipes/stackoverflow/package.json new file mode 100644 index 0000000..6b41dd5 --- /dev/null +++ b/recipes/stackoverflow/package.json @@ -0,0 +1,11 @@ +{ + "id": "stackoverflow", + "name": "Stackoverflow", + "version": "0.0.1", + "license": "MIT", + "repository": "https://github.com/christianascone/franz-recipe-stackoverflow", + "config": { + "serviceURL": "https://stackoverflow.com", + "hasNotificationSound": true + } +} diff --git a/recipes/stackoverflow/service.css b/recipes/stackoverflow/service.css new file mode 100644 index 0000000..b453fd4 --- /dev/null +++ b/recipes/stackoverflow/service.css @@ -0,0 +1,5 @@ +.app-wrapper-web .app { + width: 100% !important; + height: 100% !important; + top: 0 !important; +} 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-54-g00ecf