WHEN UPDATE?!

Show them plebs the way!

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         WHEN UPDATE?!
// @version      0.2
// @description  Show them plebs the way!
// @author       Gisbert
// @match        https://chods-cheats.com/forums/*
// @run-at       document-idle
// @namespace https://greasyfork.org/users/181293
// ==/UserScript==

var key = "";
var msg = 'The+EFT+hack+is+outdated%21+It+will+%28most+likely%29+be+updated+on+monday.+You+will+get+some+days+added+to+your+subscription+once+the+hack+is+back+up+and+running%21';
var lastmsg;

(function() {
    var origOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
        this.addEventListener('load', function() {
            //console.log('XHR finished loading', method, url);
            if( url.includes('app=bimchatbox&module=chatbox&controller=chatbox&do=getMessages')){
                var url_thing = new URL(url);
                key = url_thing.searchParams.get("csrfKey");
                display();
            }
        });
        this.addEventListener('error', function() {
            //console.log('XHR errored out', method, url);
        });
        origOpen.apply(this, arguments);
    };
})();

function contains(target, pattern) {
    var value = 0;
    pattern.forEach(function(word) {
        value = value + target.includes(word);
    });
    if (value >= 3) {
        return true;
    } else {
        return false;
    }
}

function send_msg(){
    var xhr = new XMLHttpRequest();
    xhr.open("POST", 'https://chods-cheats.com/?app=bimchatbox&module=chatbox&controller=chatbox&do=chat', true);
    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
    xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
    xhr.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");

    xhr.onreadystatechange = function() {
        if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
            // okay
        }
    };
    xhr.send("csrfKey=" + key +"&txt=" + msg);
}

function display(){
    var node = document.querySelectorAll('.ipsDataItem.chat_row')[99].querySelector('.ipsList_inline').textContent;
    var blacklist = ['EFT', 'hack', 'updated', 'cheat', 'usable', 'working', 'work', 'dont', 'when']; // expand it more?

    if (lastmsg != node && node != msg){
        if(contains(node, blacklist)){
            console.log("I'VE SENT A MESSAGE! YOU SHOULD SEE IT IN THE CHATBOX!");
            send_msg();
        }
    }
    lastmsg = node;
}