I
I
IvanSkor2020-09-28 11:47:29
JavaScript
IvanSkor, 2020-09-28 11:47:29

How to fix the script for clicking on a timer?

There is this script:

// Точное время, когда выполнить команду
var whenDate = new Date(2020, 5, 28, 9, 0, 0, 0); // 28 июня 2020 г. 09:00:00.000 (9 утра)
// Точное время сейчас
var nowDate = new Date();

// Ставим таймер, который нажмёт на зелёную кнопку
// на сайте Тостер "Задать вопрос" ровно в 9 утра.
setTimeout(function() {
    document.querySelector(".btn_add-question").click()
}, whenDate-nowDate);

for some reason when I send it to the console it clicks the button right away. How can this be fixed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Khegay, 2020-09-28
@khegay

The delay value is negative, in this case , the browser substitutes 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question