D
D
dEnisHamer2020-07-02 20:45:18
JavaScript
dEnisHamer, 2020-07-02 20:45:18

How to write auto-send message in web telegram?

Hello.
There is a telegram chat where you need to show your activity and for this you will receive points.
An activity is considered to have sent a message. Those. one message = one activity.
During the month, you need to gain as much activity as possible, and writing messages manually is not an option. And I decided to write a script.
Coincidentally, I recently started learning web programming, and now I know a little JS. And so I decided to use tampermonkey for this. Wrote a very simple script:

// ==UserScript==
// @name New Userscript
// Ilya Kovalevsky tampermonkey.net
// @version 0.1
// @description try to take over the world!
// author You
// @match https://web.telegram.org/
// @grant none
// ==/UserScript==

setTimeout(function(){
let mainInput = document.querySelector('div[placeholder="Write a message ..."]');
let mainButton = document.querySelector(`button[ng-class="draftMessage.type == 'edit' ? 'im_submit_edit' : 'im_submit_send'"]`);

let message = "Hi" ,
message1 = "How are you?",
message2 = "Good";

mainInput.innerText = message;

mainButton.click();

console.log("It worked");
},2000);

At the end of mainButton.click(); It does not work if it is a button to send a message in a web telegram( Send ).
Are there any other methods how to send a message in a cart?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cython, 2020-07-02
@dEnisHamer

For such purposes, there is a Telegram API
For Node.JS, there are many libraries for working with the API

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question