Skip to content

Instantly share code, notes, and snippets.

@jeznag
Created August 31, 2023 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeznag/973cd74b1ff0d9f20f7e9302b6ccb20d to your computer and use it in GitHub Desktop.
Save jeznag/973cd74b1ff0d9f20f7e9302b6ccb20d to your computer and use it in GitHub Desktop.
Safe Slack
// ==UserScript==
// @name Safe Slack
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hide channels + messages
// @author You
// @match https://app.slack.com/client/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=slack.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const yusomeanCSS = document.createElement('style');
yusomeanCSS.id = 'yusomeanCSS';
yusomeanCSS.innerHTML = `
#safe-slack-sidebar-div {
width: 250px;
position: absolute;
top: 100px;
left: 0;
background-color: black;
height: 100%;
z-index: 9999999999999;
color: white;
}
#safe-slack-message-div {
width: 100%;
position: absolute;
top: 100px;
left: 0;
background-color: black;
height: 100%;
z-index: 9999999999999;
color: white;
}
#safe-slack-message-div button {
background: white;
margin: 150px;
font-size: 50px;
border-color: red;
border-width: 10px;
}
`;
document.body.appendChild(yusomeanCSS);
let sidebarDiv = null;
let messageDiv = null;
let unblockButton = null;
function handleSlack() {
if (!sidebarDiv) {
sidebarDiv = document.createElement('div');
sidebarDiv.id = 'safe-slack-sidebar-div';
sidebarDiv.innerHTML = `<h1>No peeking</h1>`;
document.body.appendChild(sidebarDiv);
}
if (!messageDiv) {
messageDiv = document.createElement('div');
messageDiv.id = 'safe-slack-message-div';
messageDiv.innerHTML = `<h1>What are you trying to achieve here?</h1>`;
document.body.appendChild(messageDiv);
unblockButton = document.createElement('button');
unblockButton.innerHTML = 'SHOW MESSAGES';
messageDiv.appendChild(unblockButton);
messageDiv.addEventListener('click', () => {
document.querySelector('#safe-slack-message-div').style.display = 'none';
setTimeout(() => {
// hide messages again
document.querySelector('#safe-slack-message-div').style.display = 'none';
}, 120_000);
})
}
}
setInterval(() => {
if (location.href.includes('slack')) {
handleSlack();
}
}, 1000);
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment