aboutsummaryrefslogtreecommitdiff
path: root/config/qutebrowser/greasemonkey/slack.js
diff options
context:
space:
mode:
Diffstat (limited to 'config/qutebrowser/greasemonkey/slack.js')
-rw-r--r--config/qutebrowser/greasemonkey/slack.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/config/qutebrowser/greasemonkey/slack.js b/config/qutebrowser/greasemonkey/slack.js
new file mode 100644
index 0000000..b1d6cc4
--- /dev/null
+++ b/config/qutebrowser/greasemonkey/slack.js
@@ -0,0 +1,36 @@
+// ==UserScript==
+// @name Slack helper
+// @namespace phenax.github.io
+// @version 0.0.0
+// @description Slack helper
+// @author Akshay Nair
+// @match *://app.slack.com/*
+// ==/UserScript==
+
+const keys = {};
+
+document.addEventListener('keydown', (e) => {
+ if (keys[e.key] && e.ctrlKey) {
+ keys[e.key]();
+ }
+});
+
+const notificationsButtons = () => document.querySelectorAll('[data-qa="banner"][class*=notifications] button');
+
+let count = 0;
+const timer = setInterval(() => {
+ const $btns = notificationsButtons();
+
+ console.log('>> Notification buttons', $btns);
+
+ Array.from($btns)
+ .filter($btn => $btn.textContent.match(/enable.*notification/))
+ .forEach($btn => {
+ $btn && $btn.click();
+ clearInterval(timer);
+ });
+
+ if (count > 10) clearInterval(timer);
+ count += 1;
+}, 1000);
+