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/slack/README.md | 5 ++++ uncompressed/slack/icon.svg | 26 +++++++++++++++++++ uncompressed/slack/index.js | 3 +++ uncompressed/slack/package.json | 17 +++++++++++++ uncompressed/slack/service.css | 3 +++ uncompressed/slack/webview.js | 55 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 109 insertions(+) create mode 100644 uncompressed/slack/README.md create mode 100644 uncompressed/slack/icon.svg create mode 100644 uncompressed/slack/index.js create mode 100644 uncompressed/slack/package.json create mode 100644 uncompressed/slack/service.css create mode 100644 uncompressed/slack/webview.js (limited to 'uncompressed/slack') diff --git a/uncompressed/slack/README.md b/uncompressed/slack/README.md new file mode 100644 index 0000000..ef51d64 --- /dev/null +++ b/uncompressed/slack/README.md @@ -0,0 +1,5 @@ +# Slack for Franz +This is the official Franz recipe for Slack + +### How to create your own Franz recipes: +* [Read the documentation](https://github.com/meetfranz/plugins) diff --git a/uncompressed/slack/icon.svg b/uncompressed/slack/icon.svg new file mode 100644 index 0000000..97b01f1 --- /dev/null +++ b/uncompressed/slack/icon.svg @@ -0,0 +1,26 @@ + + + + Service/Slack + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uncompressed/slack/index.js b/uncompressed/slack/index.js new file mode 100644 index 0000000..e8243fb --- /dev/null +++ b/uncompressed/slack/index.js @@ -0,0 +1,3 @@ +"use strict"; + +module.exports = Franz => Franz; \ No newline at end of file diff --git a/uncompressed/slack/package.json b/uncompressed/slack/package.json new file mode 100644 index 0000000..8df473a --- /dev/null +++ b/uncompressed/slack/package.json @@ -0,0 +1,17 @@ +{ + "id": "slack", + "name": "Slack", + "version": "1.0.9", + "description": "Slack", + "main": "index.js", + "author": "Stefan Malzner ", + "license": "MIT", + "config": { + "serviceURL": "https://{teamId}.slack.com", + "hasNotificationSound": true, + "hasDirectMessages": true, + "hasIndirectMessages": true, + "hasTeamId": true, + "urlInputSuffix": ".slack.com" + } +} diff --git a/uncompressed/slack/service.css b/uncompressed/slack/service.css new file mode 100644 index 0000000..1dd6209 --- /dev/null +++ b/uncompressed/slack/service.css @@ -0,0 +1,3 @@ +#banner { + display: none !important; +} \ No newline at end of file diff --git a/uncompressed/slack/webview.js b/uncompressed/slack/webview.js new file mode 100644 index 0000000..98c6136 --- /dev/null +++ b/uncompressed/slack/webview.js @@ -0,0 +1,55 @@ +"use strict"; + +var _electron = require("electron"); + +var _path = _interopRequireDefault(require("path")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const getTeamIcon = function getTeamIcon(count = 0) { + let countTeamIconCheck = count; + let bgUrl = null; + const teamMenu = document.querySelector('#team_menu'); + + if (teamMenu) { + teamMenu.click(); + const icon = document.querySelector('.team_icon'); + + if (icon) { + bgUrl = window.getComputedStyle(icon, null).getPropertyValue('background-image'); + bgUrl = /^url\((['"]?)(.*)\1\)$/.exec(bgUrl); + bgUrl = bgUrl ? bgUrl[2] : ''; + } + + setTimeout(() => { + document.querySelector('.team_menu').remove(); + document.querySelector('#msg_input .ql-editor').focus(); + }, 10); + } + + countTeamIconCheck += 1; + + if (bgUrl) { + _electron.ipcRenderer.sendToHost('avatar', bgUrl); + } else if (countTeamIconCheck <= 5) { + setTimeout(() => { + getTeamIcon(countTeamIconCheck + 1); + }, 2000); + } +}; + +const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)'; + +module.exports = Franz => { + const getMessages = () => { + const directMessages = document.querySelectorAll(`${SELECTOR_CHANNELS_UNREAD} .p-channel_sidebar__badge`).length; + const allMessages = document.querySelectorAll(SELECTOR_CHANNELS_UNREAD).length - directMessages; + Franz.setBadge(directMessages, allMessages); + }; + + Franz.loop(getMessages); + setTimeout(() => { + getTeamIcon(); + }, 4000); + Franz.injectCSS(_path.default.join(__dirname, 'service.css')); +}; \ No newline at end of file -- cgit v1.2.3-70-g09d2