From 35e16bd72abb23a0b39512f503b2786bec6e11d3 Mon Sep 17 00:00:00 2001 From: Brian Choromanski Date: Wed, 23 Nov 2022 17:20:12 -0500 Subject: Added getMessages function to Snapchat --- recipes/snapchat/package.json | 2 +- recipes/snapchat/webview.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'recipes') diff --git a/recipes/snapchat/package.json b/recipes/snapchat/package.json index 50d7e01..e7c9408 100644 --- a/recipes/snapchat/package.json +++ b/recipes/snapchat/package.json @@ -1,7 +1,7 @@ { "id": "snapchat", "name": "Snapchat", - "version": "1.1.0", + "version": "1.1.1", "license": "MIT", "config": { "serviceURL": "https://web.snapchat.com/" diff --git a/recipes/snapchat/webview.js b/recipes/snapchat/webview.js index 86bb422..78a2455 100644 --- a/recipes/snapchat/webview.js +++ b/recipes/snapchat/webview.js @@ -5,12 +5,14 @@ function _interopRequireDefault(obj) { } module.exports = Ferdium => { - // TODO: If your SNAME service has unread messages, uncomment these lines to implement the logic for updating the badges - // const getMessages = () => { - // // TODO: Insert your notification-finding code here - // Ferdium.setBadge(0, 0); - // }; - // Ferdium.loop(getMessages); + const getMessages = () => { + const title = document.querySelector('title').textContent.match(/\d+/); + const count = title !== null ? title[0] : 0; + + Ferdium.setBadge(count); + }; + + Ferdium.loop(getMessages); Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); }; -- cgit v1.2.3-54-g00ecf