Last active
July 8, 2020 11:07
-
-
Save anevins12/4ba12e7ca6b3b04a5d2c2cc36e33331c to your computer and use it in GitHub Desktop.
Slack.com: Stop yourself from replying immediately to threads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Slack cool-down | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Have the urge to respond immediately to a new thread? Hit the cool-down button until you're ready. | |
// @author anevins12 | |
// @match https://app.slack.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
const styles = ` | |
.cool-down-trigger { | |
background-color: #350d36; | |
color: white; | |
padding: 5px 10px; | |
position: absolute; | |
right: 10px; | |
top: 4em; | |
z-index: 9999; | |
} | |
@media screen and (min-width: 768px) { | |
.cool-down-trigger { | |
border: 1px solid #eee; | |
left: 10px; | |
position: absolute; | |
right: auto; | |
top: 5px; | |
} | |
} | |
[data-js="slack-cool-down"] { | |
position: relative; | |
} | |
[data-js="slack-cool-down"]::after { | |
background-color: #fff; | |
bottom: 0; | |
color: #000; | |
content: 'Take a break'; | |
font-size: 2em; | |
height: 100%; | |
left: 0; | |
opacity: 0.8; | |
padding-left: 0.2em; | |
position: absolute; | |
width: 100%; | |
z-index: 200; | |
}`; | |
const $trigger = document.createElement('button'); | |
const triggerFlag = 'slack-cool-down'; | |
const style = document.createElement('style'); | |
const ref = document.querySelector('script'); | |
const triggerClass = 'cool-down-trigger--on'; | |
const triggerHTML = 'Cool-down replies'; | |
$trigger.classList.add('cool-down-trigger'); | |
$trigger.innerHTML = triggerHTML; | |
style.innerHTML = styles; | |
// Insert our new styles before the first script tag | |
ref.parentNode.insertBefore(style, ref); | |
$trigger.addEventListener('click', function() { | |
const $targets = document.querySelectorAll('.p-threads_footer__input'); | |
for (var i = 0; i < $targets.length; ++i) { | |
var $target = $targets[i]; | |
if ($target.hasAttribute('data-js')) { | |
$target.removeAttribute('data-js'); | |
$trigger.classList.remove(triggerClass); | |
$trigger.innerHTML = triggerHTML; | |
} else { | |
$target.setAttribute('data-js', triggerFlag); | |
$trigger.classList.add(triggerClass); | |
$trigger.innerHTML = 'Turn off cool-down replies'; | |
} | |
} | |
}); | |
document.body.appendChild($trigger); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a tampermonkey script and relies on the 'tampermonkey' browser extension.
The purpose of this script is to help people using Slack to control their impulses on replying. It's easy for someone to say "You don't have to reply straight away" but not always that easy to do.
This script provides a button in the Web interface of Slack named "Cool-down replies". Pressing it disables the comment box. Pressing it again removes the cool-down and enables the comment box.
More info available on Dev.to: https://dev.to/anevins12/slack-you-don-t-have-to-reply-so-fast-6mf