LoginSignup
10
8

More than 5 years have passed since last update.

Slackで特定のボットやユーザーを無視するgreasemonkeyスクリプト

Last updated at Posted at 2015-05-24

背景

CSS - slack で join/left のメッセージを消す - Qiita
とか
Slack - 人間の会話だけに絞る - Qiita
とか
Slackで特定の名前を持つボットやユーザーをミュートするブックマークレット - Qiita
とかに触発されてgreasemonkeyスクリプトを書きました。
slackドメインのページを開くと勝手にそれらを実行してくれます。

コード

Ignore Slack User - Greasy Fork

// ==UserScript==
// @name         Ignore Slack User
// @namespace    https://greasyfork.org/ja/scripts/10042
// @version      1.0.0
// @description  Ignore a user in Slack
// @author       bigwheel
// @match        https://*.slack.com/*
// @grant        none
// ==/UserScript==

// ここに無視したいユーザー・ボットの名前を並べる
var usersToBeIgnored = new Array("user1", "user2");

if(document.body) {
    $("#msgs_div").on('DOMSubtreeModified propertychange', function() {
        usersToBeIgnored.forEach(function(user) {
            $("div.message > *.message_sender:contains(" + user + ")").parent().hide();
        });

        // ボットメッセージを一括無視したい場合はコメントイン
        // $(".bot_message").hide();

        // join/left メッセージを無視
        $(".joined").hide();
        $(".left").hide();
    });
};

使い方

無視したいボット・ユーザーの名前をusersToBeIgnoredへ書いてください。
またボットのメッセージをすべて非表示にしたい場合は真ん中のコードをコメントインすればOK。

10
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
8