From 34471638f12398f8b474c45ed8609299935f769a Mon Sep 17 00:00:00 2001 From: Dustin Date: Tue, 27 Oct 2020 18:20:38 +0000 Subject: Add recipe for Wire (#344) Co-authored-by: Amine Mouafik --- recipes/wire/LICENSE | 21 +++++++++++++++++++++ recipes/wire/README.md | 3 +++ recipes/wire/icon.png | Bin 0 -> 35371 bytes recipes/wire/icon.svg | 10 ++++++++++ recipes/wire/index.js | 1 + recipes/wire/package.json | 18 ++++++++++++++++++ recipes/wire/webview.js | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 91 insertions(+) create mode 100644 recipes/wire/LICENSE create mode 100644 recipes/wire/README.md create mode 100644 recipes/wire/icon.png create mode 100644 recipes/wire/icon.svg create mode 100644 recipes/wire/index.js create mode 100644 recipes/wire/package.json create mode 100644 recipes/wire/webview.js (limited to 'recipes/wire') diff --git a/recipes/wire/LICENSE b/recipes/wire/LICENSE new file mode 100644 index 0000000..fd3ae1e --- /dev/null +++ b/recipes/wire/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Dustin Steiner + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/recipes/wire/README.md b/recipes/wire/README.md new file mode 100644 index 0000000..1aa662b --- /dev/null +++ b/recipes/wire/README.md @@ -0,0 +1,3 @@ +# Wire for Ferdi + +This is a Ferdi recipe/plugin for the messenger Wire (https://wire.com) diff --git a/recipes/wire/icon.png b/recipes/wire/icon.png new file mode 100644 index 0000000..5b5cf6e Binary files /dev/null and b/recipes/wire/icon.png differ diff --git a/recipes/wire/icon.svg b/recipes/wire/icon.svg new file mode 100644 index 0000000..3b5c25a --- /dev/null +++ b/recipes/wire/icon.svg @@ -0,0 +1,10 @@ + + + Untitled + + + + + + + \ No newline at end of file diff --git a/recipes/wire/index.js b/recipes/wire/index.js new file mode 100644 index 0000000..653b54c --- /dev/null +++ b/recipes/wire/index.js @@ -0,0 +1 @@ +module.exports = (Ferdi) => Ferdi; diff --git a/recipes/wire/package.json b/recipes/wire/package.json new file mode 100644 index 0000000..7849162 --- /dev/null +++ b/recipes/wire/package.json @@ -0,0 +1,18 @@ +{ + "id": "wire", + "name": "Wire", + "version": "1.0.0", + "description": "Modern day collaboration meets the most advanced security and superior user experience.", + "main": "index.js", + "author": "Dustin Steiner ", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/getferdi/", + "directory": "recipes/wire" + }, + "config": { + "serviceURL": "https://app.wire.com/", + "hasIndirectMessages": true + } +} diff --git a/recipes/wire/webview.js b/recipes/wire/webview.js new file mode 100644 index 0000000..57baadc --- /dev/null +++ b/recipes/wire/webview.js @@ -0,0 +1,38 @@ +module.exports = (Ferdi) => { + function getMessages() { + let direct = 0; + let indirect = 0; + + // Count how many people/groups have texted you + const conversationElems = document.querySelectorAll('[data-uie-name="conversation-folder-badge"]'); + if (conversationElems) { + for (const conversationElem of conversationElems) { + const count = parseInt(conversationElem.innerText); + if (count) { + direct += count; + } + } + } + + // Count unread pending user requests + const pendingElem = document.querySelector('[data-uie-name="item-pending-requests"]'); + if (pendingElem) { + const matches = pendingElem.innerText.match(/^([1-9][0-9]*)/); + if (matches && matches.length > 0) { + indirect += parseInt(matches[1]); + } + } + + // Alternative would be to count all messages (unread conversation count + pending) from the header + // const titleElem = document.querySelector('head title'); + // const matches = titleElem.innerText.match(/^\(([1-9][0-9]*)\)/); + // if (matches) { + // direct = matches[1]; + // } + + Ferdi.setBadge(direct, indirect); + } + + Ferdi.loop(getMessages); + +}; -- cgit v1.2.3-70-g09d2