diff options
| author | Akshay Nair <phenax5@gmail.com> | 2020-12-21 18:52:51 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2020-12-21 18:52:51 +0530 |
| commit | f1cf59ce2df9204f818cfd038538a2a31a5c2262 (patch) | |
| tree | 35b0a21501615b7551514262b96e9d8113375cbc /config/qutebrowser/greasemonkey/slack.js | |
| parent | 6ff5a17adcf1ed72cd2f1c7bff606bdd3352b3bb (diff) | |
| download | nixos-config-f1cf59ce2df9204f818cfd038538a2a31a5c2262.tar.gz nixos-config-f1cf59ce2df9204f818cfd038538a2a31a5c2262.zip | |
Adds qutebrowser config
Diffstat (limited to 'config/qutebrowser/greasemonkey/slack.js')
| -rw-r--r-- | config/qutebrowser/greasemonkey/slack.js | 36 |
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); + |
