Basic KongChat Filter

Basic filter to remove messages sent by the recent chat bots.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Basic KongChat Filter
// @namespace   Basic KongChat Filter
// @match       https://www.kongregate.com/games/*
// @grant       none
// @version     1.4.6
// @author      Lexiebean <[email protected]>
// @description Basic filter to remove messages sent by the recent chat bots.
// @license     GNU GPLv3
// ==/UserScript==

// *********** This script will stop working as soon as the bots update their message. DM me on discord and I'll update it. @Lexie#4024 ***********

function KongFilter() {
  var els = document.getElementsByClassName("chat-message");
  var searchValue = /(s(e|е)xy|nud(e|е).*http)/;                            //This is the message that we're looking to remove.

  //Look for spam in the last 5 messages -- Last 5 just incase 5 messages come in on a same second.
  for(var i = els.length-5; i < els.length ; i++){
    if(els[i]) {
      if (searchValue.test(els[i].innerHTML)) {
      
        spamRemoved++;
        localStorage.setItem("BKCFspamRemoved", spamRemoved);
        span.innerHTML = "Spam Removed:" + spamRemoved;
      
        var username = els[i].getElementsByTagName("span")[1].getAttribute('username');
        var searchValuej = new RegExp(username);
      
        console.log('[Basic KongChat Filter] (' + spamRemoved + ') Removing > ' + username + ': ' + els[i].getElementsByTagName("span")[3].innerHTML);   //Log the removed message
        els[i].remove();
      
        for (var j = els.length-10; j < els.length; j++){
          if(els[j]) {
            if (searchValuej.test(els[j].innerHTML)) {           
              console.log('[Basic KongChat Filter] (' + spamRemoved + ') Removing > ' + username + ': ' + els[j].getElementsByTagName("span")[3].innerHTML);   //Log the removed message
              els[j].remove();
            }
          }
        }
      }
    }
  }
}


console.log('[Basic KongChat Filter] Initializing...');

spamRemoved = 0;
//Load spamRemoved count
if (localStorage.getItem("BKCFspamRemoved")) {
  spamRemoved = localStorage.getItem("BKCFspamRemoved");
}

//Create <span> to display spamRemoved Count
var span = document.createElement("SPAN");
span.style.float = "right";
span.innerHTML = "Spam Removed:" + spamRemoved;

function initialise() {

  var hook = document.getElementById("chat_window_header").children[0];

  if (hook) { 
    hook.appendChild(span);
    setInterval(KongFilter, 1000);
    console.log('[Basic KongChat Filter] Loaded!');
    console.log('[Basic KongChat Filter] Total Removed: ' + spamRemoved);
    clearInterval(initialise);
  }
}

var initialise = setInterval(initialise, 1000);