ANTICHAT

ANTICHAT (https://forum.antichat.xyz/index.php)
-   Общие вопросы программирования (https://forum.antichat.xyz/forumdisplay.php?f=206)
-   -   Помощь с скриптом для Tampermonkey (https://forum.antichat.xyz/showthread.php?t=1320099)

XyJluraH 25.01.2018 13:31

Нужен мини скрип для расширения tampermonkey , который будет чекать чат на сайте , если какой нибудь пользователь напишет слово - 1, скрипт автоматом напишет - 2 . Кто шарит в этом помогите пожалуйста )

Уже помогли с 1 скриптом, который каждые 30 секунд вводит в чат слово - Отметка

Код:





Код:

(function timeS() {
    var input = document.querySelector('.chat-input');

    if (input) {
        input.value = 'Отметка';

        var inputSend = document.querySelector('.chatInputSend');
        if (inputSend)
            inputSend.click();
    }

    setTimeout(timeS, 30000);
})();


kawa operand 25.01.2018 15:13

https://forum.antichat.xyz/attachments/27179896/

itsLegend 25.01.2018 17:00

Тебе наверно стоило показать этот самый чат.

itsLegend 25.01.2018 18:00

(для Violentmonkey, под Greasemonkey тоже должен подходить)

Чекает исключительно последнюю строчку из чата каждые 70 миллисекунд (по таймеру).

JavaScript:





Код:

// ==UserScript==
// @name gamdom chat bot
// @namespace Violentmonkey Scripts
// @match https://gamdom.com/*
// @match https://www.gamdom.com/*
// @require http://code.jquery.com/jquery-3.3.1.min.js
// @grant none
// ==/UserScript==
var
lastMessage
=
''
;
const
waitChat
=
setInterval
(
(
)
=>
{
//console.log('check');
const
$chatMessages
=
$
(
'#chat ul.messages li.msg-chat-message'
)
;
if
(
$chatMessages
&&
$chatMessages
.
length
>
0
)
{
const
message
=
$chatMessages
.
last
(
)
.
text
(
)
;
if
(
message
!=
lastMessage
)
{
lastMessage
=
message
;
console
.
log
(
message
)
;
if
(
message
==
'5+1'
)
{
// answer -> 6
}
}
}
}
,
70
)
;


XyJluraH 25.01.2018 19:29

Цитата:

Сообщение от legend2360

(для Violentmonkey, под Greasemonkey тоже должен подходить)
Чекает исключительно последнюю строчку из чата каждые 70 миллисекунд (по таймеру).

JavaScript:





Код:

// ==UserScript==
// @name gamdom chat bot
// @namespace Violentmonkey Scripts
// @match https://gamdom.com/*
// @match https://www.gamdom.com/*
// @require http://code.jquery.com/jquery-3.3.1.min.js
// @grant none
// ==/UserScript==
var
lastMessage
=
''
;
const
waitChat
=
setInterval
(
(
)
=>
{
//console.log('check');
const
$chatMessages
=
$
(
'#chat ul.messages li.msg-chat-message'
)
;
if
(
$chatMessages
&&
$chatMessages
.
length
>
0
)
{
const
message
=
$chatMessages
.
last
(
)
.
text
(
)
;
if
(
message
!=
lastMessage
)
{
lastMessage
=
message
;
console
.
log
(
message
)
;
if
(
message
==
'5+1'
)
{
// answer -> 6
}
}
}
}
,
70
)
;



Спасибо! А что я должен написать в чат чтобы сразу бот отправлял за моим сообщением?

kawa operand 25.01.2018 19:32

Цитата:

Сообщение от legend2360

5+1


XyJluraH 25.01.2018 19:38

Странно, ничего не происходит, не знаю в чем проблема (


Время: 09:13