From 2ce7cb8f6dfc20a634ac639fc08fc3bc3048c79b Mon Sep 17 00:00:00 2001 From: Vijay Aravamudhan Date: Sun, 12 Sep 2021 17:38:08 +0530 Subject: New recipe: 'hey' (#701) --- recipes/hey/LICENSE | 21 ++++++++++++++ recipes/hey/icon.svg | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ recipes/hey/index.js | 1 + recipes/hey/package.json | 10 +++++++ recipes/hey/webview.js | 28 +++++++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 recipes/hey/LICENSE create mode 100644 recipes/hey/icon.svg create mode 100644 recipes/hey/index.js create mode 100644 recipes/hey/package.json create mode 100644 recipes/hey/webview.js (limited to 'recipes/hey') diff --git a/recipes/hey/LICENSE b/recipes/hey/LICENSE new file mode 100644 index 0000000..1836cd1 --- /dev/null +++ b/recipes/hey/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Chris Wood + +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/hey/icon.svg b/recipes/hey/icon.svg new file mode 100644 index 0000000..376f7d0 --- /dev/null +++ b/recipes/hey/icon.svg @@ -0,0 +1,71 @@ + + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + image/svg+xml + + + + + + + + + + diff --git a/recipes/hey/index.js b/recipes/hey/index.js new file mode 100644 index 0000000..23607bd --- /dev/null +++ b/recipes/hey/index.js @@ -0,0 +1 @@ +module.exports = Ferdi => Ferdi; diff --git a/recipes/hey/package.json b/recipes/hey/package.json new file mode 100644 index 0000000..02b1334 --- /dev/null +++ b/recipes/hey/package.json @@ -0,0 +1,10 @@ +{ + "id": "hey", + "name": "Hey", + "version": "1.0.0", + "repository": "https://github.com/cpwood/recipe-hey", + "config": { + "serviceURL": "https://app.hey.com", + "hasIndirectMessages": true + } +} diff --git a/recipes/hey/webview.js b/recipes/hey/webview.js new file mode 100644 index 0000000..d3227af --- /dev/null +++ b/recipes/hey/webview.js @@ -0,0 +1,28 @@ +module.exports = (Ferdi) => { + const getMessages = function getMessages() { + if (document.location.href == "https://app.hey.com/") { + let screener = 0; + let unread = 0; + + if (document.getElementsByClassName('btn--icon-screener').length > 0) { + let text = document.getElementsByClassName('btn--icon-screener')[0].innerText; + + screener = Ferdi.safeParseInt(/[0-9]+/.exec(text)[0]); + } + + let postings = document.getElementsByClassName('posting'); + + if (postings.length > 0) { + Array.from(postings).forEach(p => { + if (p.nodeName == "ARTICLE" && p.getAttribute("data-seen") !== "true") { + unread++; + } + }); + } + + Ferdi.setBadge(unread, screener); + } + }; + + Ferdi.loop(getMessages); +} -- cgit v1.2.3-54-g00ecf