aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/slack
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/slack')
-rw-r--r--recipes/slack/README.md5
-rw-r--r--recipes/slack/icon.pngbin0 -> 69225 bytes
-rw-r--r--recipes/slack/icon.svg26
-rw-r--r--recipes/slack/index.js3
-rw-r--r--recipes/slack/package.json17
-rw-r--r--recipes/slack/service.css3
-rw-r--r--recipes/slack/webview.js54
7 files changed, 108 insertions, 0 deletions
diff --git a/recipes/slack/README.md b/recipes/slack/README.md
new file mode 100644
index 0000000..ef51d64
--- /dev/null
+++ b/recipes/slack/README.md
@@ -0,0 +1,5 @@
1# Slack for Franz
2This is the official Franz recipe for Slack
3
4### How to create your own Franz recipes:
5* [Read the documentation](https://github.com/meetfranz/plugins)
diff --git a/recipes/slack/icon.png b/recipes/slack/icon.png
new file mode 100644
index 0000000..ed56a11
--- /dev/null
+++ b/recipes/slack/icon.png
Binary files differ
diff --git a/recipes/slack/icon.svg b/recipes/slack/icon.svg
new file mode 100644
index 0000000..97b01f1
--- /dev/null
+++ b/recipes/slack/icon.svg
@@ -0,0 +1,26 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<svg width="80px" height="80px" viewBox="0 0 80 80" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3 <!-- Generator: Sketch 52.6 (67491) - http://www.bohemiancoding.com/sketch -->
4 <title>Service/Slack</title>
5 <desc>Created with Sketch.</desc>
6 <g id="Service/Slack" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
7 <g id="Slack_Mark">
8 <g id="Group" transform="translate(0.000000, 42.000000)" fill="#E01E5A">
9 <path d="M17.0033898,8.50169492 C17.0033898,13.0745763 13.2677966,16.8101695 8.69491525,16.8101695 C4.1220339,16.8101695 0.386440678,13.0745763 0.386440678,8.50169492 C0.386440678,3.92881356 4.1220339,0.193220339 8.69491525,0.193220339 L17.0033898,0.193220339 L17.0033898,8.50169492 Z" id="Path"></path>
10 <path d="M21.1898305,8.50169492 C21.1898305,3.92881356 24.9254237,0.193220339 29.4983051,0.193220339 C34.0711864,0.193220339 37.8067797,3.92881356 37.8067797,8.50169492 L37.8067797,29.3050847 C37.8067797,33.8779661 34.0711864,37.6135593 29.4983051,37.6135593 C24.9254237,37.6135593 21.1898305,33.8779661 21.1898305,29.3050847 L21.1898305,8.50169492 Z" id="Path"></path>
11 </g>
12 <g id="Group" fill="#36C5F0">
13 <path d="M29.4983051,17.0033898 C24.9254237,17.0033898 21.1898305,13.2677966 21.1898305,8.69491525 C21.1898305,4.1220339 24.9254237,0.386440678 29.4983051,0.386440678 C34.0711864,0.386440678 37.8067797,4.1220339 37.8067797,8.69491525 L37.8067797,17.0033898 L29.4983051,17.0033898 Z" id="Path"></path>
14 <path d="M29.4983051,21.1898305 C34.0711864,21.1898305 37.8067797,24.9254237 37.8067797,29.4983051 C37.8067797,34.0711864 34.0711864,37.8067797 29.4983051,37.8067797 L8.69491525,37.8067797 C4.1220339,37.8067797 0.386440678,34.0711864 0.386440678,29.4983051 C0.386440678,24.9254237 4.1220339,21.1898305 8.69491525,21.1898305 L29.4983051,21.1898305 Z" id="Path"></path>
15 </g>
16 <g id="Group" transform="translate(42.000000, 0.000000)" fill="#2EB67D">
17 <path d="M20.9966102,29.4983051 C20.9966102,24.9254237 24.7322034,21.1898305 29.3050847,21.1898305 C33.8779661,21.1898305 37.6135593,24.9254237 37.6135593,29.4983051 C37.6135593,34.0711864 33.8779661,37.8067797 29.3050847,37.8067797 L20.9966102,37.8067797 L20.9966102,29.4983051 Z" id="Path"></path>
18 <path d="M16.8101695,29.4983051 C16.8101695,34.0711864 13.0745763,37.8067797 8.50169492,37.8067797 C3.92881356,37.8067797 0.193220339,34.0711864 0.193220339,29.4983051 L0.193220339,8.69491525 C0.193220339,4.1220339 3.92881356,0.386440678 8.50169492,0.386440678 C13.0745763,0.386440678 16.8101695,4.1220339 16.8101695,8.69491525 L16.8101695,29.4983051 Z" id="Path"></path>
19 </g>
20 <g id="Group" transform="translate(42.000000, 42.000000)" fill="#ECB22E">
21 <path d="M8.50169492,20.9966102 C13.0745763,20.9966102 16.8101695,24.7322034 16.8101695,29.3050847 C16.8101695,33.8779661 13.0745763,37.6135593 8.50169492,37.6135593 C3.92881356,37.6135593 0.193220339,33.8779661 0.193220339,29.3050847 L0.193220339,20.9966102 L8.50169492,20.9966102 Z" id="Path"></path>
22 <path d="M8.50169492,16.8101695 C3.92881356,16.8101695 0.193220339,13.0745763 0.193220339,8.50169492 C0.193220339,3.92881356 3.92881356,0.193220339 8.50169492,0.193220339 L29.3050847,0.193220339 C33.8779661,0.193220339 37.6135593,3.92881356 37.6135593,8.50169492 C37.6135593,13.0745763 33.8779661,16.8101695 29.3050847,16.8101695 L8.50169492,16.8101695 Z" id="Path"></path>
23 </g>
24 </g>
25 </g>
26</svg> \ No newline at end of file
diff --git a/recipes/slack/index.js b/recipes/slack/index.js
new file mode 100644
index 0000000..e8243fb
--- /dev/null
+++ b/recipes/slack/index.js
@@ -0,0 +1,3 @@
1"use strict";
2
3module.exports = Franz => Franz; \ No newline at end of file
diff --git a/recipes/slack/package.json b/recipes/slack/package.json
new file mode 100644
index 0000000..8463e88
--- /dev/null
+++ b/recipes/slack/package.json
@@ -0,0 +1,17 @@
1{
2 "id": "slack",
3 "name": "Slack",
4 "version": "1.0.16",
5 "description": "Slack",
6 "main": "index.js",
7 "author": "Stefan Malzner <stefan@adlk.io>",
8 "license": "MIT",
9 "config": {
10 "serviceURL": "https://{teamId}.slack.com",
11 "hasNotificationSound": true,
12 "hasDirectMessages": true,
13 "hasIndirectMessages": true,
14 "hasTeamId": true,
15 "urlInputSuffix": ".slack.com"
16 }
17}
diff --git a/recipes/slack/service.css b/recipes/slack/service.css
new file mode 100644
index 0000000..1dd6209
--- /dev/null
+++ b/recipes/slack/service.css
@@ -0,0 +1,3 @@
1#banner {
2 display: none !important;
3} \ No newline at end of file
diff --git a/recipes/slack/webview.js b/recipes/slack/webview.js
new file mode 100644
index 0000000..f7bccfc
--- /dev/null
+++ b/recipes/slack/webview.js
@@ -0,0 +1,54 @@
1"use strict";
2
3var _electron = require("electron");
4
5var _path = _interopRequireDefault(require("path"));
6
7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
9const getTeamIcon = function getTeamIcon(count = 0) {
10 let countTeamIconCheck = count;
11 let bgUrl = null;
12 const teamMenu = document.querySelector('#team-menu-trigger, .p-ia__sidebar_header__team_name');
13
14 if (teamMenu) {
15 teamMenu.click();
16 const icon = document.querySelector('.c-team_icon');
17
18 if (icon) {
19 bgUrl = window.getComputedStyle(icon, null).getPropertyValue('background-image');
20 bgUrl = /^url\((['"]?)(.*)\1\)$/.exec(bgUrl);
21 bgUrl = bgUrl ? bgUrl[2] : '';
22 }
23
24 setTimeout(() => {
25 document.querySelector('.ReactModal__Overlay').click();
26 }, 10);
27 }
28
29 countTeamIconCheck += 1;
30
31 if (bgUrl) {
32 _electron.ipcRenderer.sendToHost('avatar', bgUrl);
33 } else if (countTeamIconCheck <= 5) {
34 setTimeout(() => {
35 getTeamIcon(countTeamIconCheck + 1);
36 }, 2000);
37 }
38};
39
40const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)';
41
42module.exports = Franz => {
43 const getMessages = () => {
44 const directMessages = document.querySelectorAll(`${SELECTOR_CHANNELS_UNREAD} .p-channel_sidebar__badge, .p-channel_sidebar__link--unread:not([data-sidebar-link-id="Punreads"]):not([data-sidebar-link-id="Pdrafts"]):not([data-sidebar-link-id="Pdms"])`).length;
45 const allMessages = document.querySelectorAll(SELECTOR_CHANNELS_UNREAD).length - directMessages;
46 Franz.setBadge(directMessages, allMessages);
47 };
48
49 Franz.loop(getMessages);
50 setTimeout(() => {
51 getTeamIcon();
52 }, 4000);
53 Franz.injectCSS(_path.default.join(__dirname, 'service.css'));
54};