From 728d339739b63e9bb59e457e4a84fe9a65b93fc9 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sat, 28 Sep 2019 12:10:25 +0200 Subject: Add uncompressed recipes --- uncompressed/mattermost/README.md | 5 +++++ uncompressed/mattermost/icon.svg | 14 ++++++++++++++ uncompressed/mattermost/index.js | 20 ++++++++++++++++++++ uncompressed/mattermost/package.json | 14 ++++++++++++++ uncompressed/mattermost/webview.js | 13 +++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 uncompressed/mattermost/README.md create mode 100644 uncompressed/mattermost/icon.svg create mode 100644 uncompressed/mattermost/index.js create mode 100644 uncompressed/mattermost/package.json create mode 100644 uncompressed/mattermost/webview.js (limited to 'uncompressed/mattermost') diff --git a/uncompressed/mattermost/README.md b/uncompressed/mattermost/README.md new file mode 100644 index 0000000..3321fb5 --- /dev/null +++ b/uncompressed/mattermost/README.md @@ -0,0 +1,5 @@ +# Mattermost for Franz +This is the official Franz recipe for Mattermost + +### How to create your own Franz recipes: +* [Read the documentation](https://github.com/meetfranz/plugins) diff --git a/uncompressed/mattermost/icon.svg b/uncompressed/mattermost/icon.svg new file mode 100644 index 0000000..9f7056d --- /dev/null +++ b/uncompressed/mattermost/icon.svg @@ -0,0 +1,14 @@ + + + + mattermost + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/uncompressed/mattermost/index.js b/uncompressed/mattermost/index.js new file mode 100644 index 0000000..8f814fa --- /dev/null +++ b/uncompressed/mattermost/index.js @@ -0,0 +1,20 @@ +"use strict"; + +module.exports = Franz => class Mattermost extends Franz { + async validateUrl(url) { + try { + const resp = await window.fetch(url, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }); + return resp.status.toString().startsWith('2'); + } catch (err) { + console.error(err); + } + + return false; + } + +}; \ No newline at end of file diff --git a/uncompressed/mattermost/package.json b/uncompressed/mattermost/package.json new file mode 100644 index 0000000..48f6860 --- /dev/null +++ b/uncompressed/mattermost/package.json @@ -0,0 +1,14 @@ +{ + "id": "mattermost", + "name": "Mattermost", + "version": "1.2.1", + "description": "Mattermost", + "main": "index.js", + "author": "Stefan Malzner ", + "license": "MIT", + "config": { + "hasNotificationSound": true, + "hasIndirectMessages": true, + "hasCustomUrl": true + } +} diff --git a/uncompressed/mattermost/webview.js b/uncompressed/mattermost/webview.js new file mode 100644 index 0000000..03258e0 --- /dev/null +++ b/uncompressed/mattermost/webview.js @@ -0,0 +1,13 @@ +"use strict"; + +module.exports = Franz => { + const getMessages = function getMessages() { + const directMessages = document.querySelectorAll('.sidebar--left .has-badge .badge').length; + const allMessages = document.querySelectorAll('.sidebar--left .has-badge').length - directMessages; + const teamDirectMessages = document.querySelectorAll('.team-wrapper .team-container .badge').length; + const teamMessages = document.querySelectorAll('.team-wrapper .unread').length - teamDirectMessages; + Franz.setBadge(directMessages + teamDirectMessages, allMessages + teamMessages); + }; + + Franz.loop(getMessages); +}; \ No newline at end of file -- cgit v1.2.3-70-g09d2