Mother Fucker Telegram Group Spammer

屏蔽 Telegram 群组成员,在下方 * 号处填入昵称然后保存即可。

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Mother Fucker Telegram Group Spammer
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  屏蔽 Telegram 群组成员,在下方 * 号处填入昵称然后保存即可。
// @author       莲华
// @match        *://web.telegram.org/*
// @homepage        https://t.me/EroSora
// @namespace        https://gist.github.com/isssuer
// @icon        https://greasyfork.org/packs/media/images/blacklogo16-5421a97c75656cecbe2befcec0778a96.png
// @icon64        https://greasyfork.org/packs/media/images/blacklogo96-b2384000fca45aa17e45eb417cbcbb59.png
// @grant        none
// ==/UserScript==

/*jshint esversion: 8 */

(function () {
  "use strict";
  //***********************************************************
  const SPAMMERS = [""];
  //**********Fill nick names in the brackets above***********
  //const SPAMMERS = ["Troll", "Phisher", "Bullshit", "Asshole "]

  const messageClass = "im_history_message_wrap";
  const grouped = "im_grouped";
  const shortGrouped = "im_grouped_short";
  const observer = new MutationObserver(mutations => {
    mutations.forEach(mutation => {
      if (mutation.addedNodes) {
        mutation.addedNodes.forEach(node => {
          if (node.className === messageClass) {
            let name, isSpammer;
            try {
              name = node.querySelector("span > a").innerText;
            } catch (e) {}
            if (name && SPAMMERS.indexOf(name) > -1) {
              console.log("Caught a fool!");
              node.style.display = "none";
              let nextNode = node.nextElementSibling;
              while (
                nextNode.classList.contains(grouped) ||
                nextNode.classList.contains(shortGrouped)
              ) {
                nextNode.style.display = "none";
                nextNode = nextNode.nextElementSibling;
              }
            }
          }
        });
      }
    });
  });
  observer.observe(document.body, { childList: true, subtree: true });
})();