stfu-slack-apps/foz.user.js
2023-11-20 10:11:50 -08:00

34 lines
1.3 KiB
JavaScript

// ==UserScript==
// @name slack-app-notif-nuker
// @namespace http://git.minimally.online/
// @version 0.1
// @description Allows you to hide Slack messages from needlessly noisy apps/individuals based on content
// @author Max
// @match *://app.slack.com/*
// @icon https://i.ibb.co/wCj7Tg5/ear-plug.png
// @grant none
// @downloadURL https://git.minimally.online/drudgesentinel/stfu-zapier/raw/branch/main/foz.user.js
// @updateURL https://git.minimally.online/drudgesentinel/stfu-zapier/raw/branch/main/foz.user.js
// ==/UserScript==
// Icon from flaticons.com
// At present, this filtration is specific to app generated messages.
// EDIT the const SPAM to select application notifs to remove
const SPAM = "KANBAN UPDATE NOTIFICATION";
const removeMessages = () => {
const messages = Array.from(document.querySelectorAll('[data-qa="virtual-list-item"]'));
const haveButtons = messages.filter(message => message.querySelector('button'));
haveButtons.forEach( (node) => removeIfSpam(node, SPAM));
}
const removeIfSpam = (node, spamMessage) => {
if(node.querySelector('button').textContent.includes(spamMessage)) {
node.replaceChildren();
}
}
//adjust this, faster is better but might impact performance idk
setInterval( removeMessages, 500);