From 6f5e4a00588aefdda7a5a1cfe70935870e7e234a Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 22 Sep 2020 20:56:48 +0200 Subject: Unpack recipes and update recipes icons (#292) Co-authored-by: Amine Mouafik --- recipes/mastodon/webview.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 recipes/mastodon/webview.js (limited to 'recipes/mastodon/webview.js') diff --git a/recipes/mastodon/webview.js b/recipes/mastodon/webview.js new file mode 100644 index 0000000..d3644e8 --- /dev/null +++ b/recipes/mastodon/webview.js @@ -0,0 +1,28 @@ +module.exports = (Franz, options) => { + let latestStatement = $('.status time').attr('datetime'); + let latestNotify = $($('.notification__message span').get(0)).text(); + + $($('div.column div.scrollable').get(0)).on('scroll', (ev) => { + latestStatement = $('.status time').attr('datetime'); + }); + $($('div.column div.scrollable').get(1)).on('scroll', (ev) => { + latestNotify = $($('.notification__message span').get(0)).text(); + }); + + function getMessages() { + var reply = 0; + const ln = $($('.notification__message span').get(0)).text(); + if (ln != latestNotify) { + reply = 1; + } + var unread = 0; + const ls = $('.status time').attr('datetime'); + if (ls != latestStatement) { + unread = 1; + } + + Franz.setBadge(reply, unread); + } + + Franz.loop(getMessages); +} -- cgit v1.2.3-70-g09d2