что не так в этом коде? не работает
пишет в консоли
TypeError: Cannot read property 'click' of undefined
at foo (eval at <anonymous> (:2:479), <anonymous>:17:70)
at eval (eval at <anonymous> (:2:479), <anonymous>:66:7)
at Window.eval (eval at <anonymous> (:2:479), <anonymous>:68:3)
at <anonymous>:2:479
at eval (eval at <anonymous> (:2:479), <anonymous>:2:1)
at eval (eval at <anonymous> (:2:479), <anonymous>:3:3)
at Object.eval (eval at <anonymous> (:2:479), <anonymous>:73:6)
at eval (eval at <anonymous> (:2:479), <anonymous>:73:50)
at eval (<anonymous>)
at <anonymous>:2:479
запускаю через тампермонкей
// ==UserScript==
// @name ТОП ФЕЙС глобал
// @namespace [url]http://tampermonkey.net/[/url]
// @version 0.1
// @description try to take over the world!
// @author You
// @match [url]https://topface.com/*[/url]
// @grant none
// ==/UserScript==
(function() {
'use strict';
(function foo(i) {
document.getElementsByClassName('label-for-online-filter')[0].click();
setInterval(function() {
if (document.getElementsByClassName('cnt cntSympathy not-null')[0].innerHTML > 0) { (function likef() {
setTimeout(function fvzaimno() {
for (i = 0; i < 100; i++) document.getElementsByClassName('blue-button press-message')[i].click();
}, 3000);
setTimeout(function() {
for (i = 0; i < 100; i++) document.getElementsByClassName('chatterbox-toggler')[i].click();
}, 7000);
setTimeout(function() {
for (i = 0; i < 100; i++) document.getElementsByClassName('blue-button chat-from-symp-button')[i].click();
},11000);
})();}
if (document.getElementsByClassName('cnt cntMessages not-null')[0].innerHTML > 30) {(function likefs() {
setInterval(function() {
var t = localStorage.getItem('q');
localStorage.setItem('q', ++t);
console.log(t);
//document.getElementsByClassName('label-for-online-filter')[0].click();
setTimeout(function lk() {
document.getElementsByClassName('messenger-contact-list-contacts-item-name')[t].click();
}, 2000);
setTimeout(function lkq() {
document.getElementsByClassName('messenger-chat-compose-input')[0].innerHTML = " ";
}, 4000);
setTimeout(function lkqq() {
document.getElementsByClassName('messenger-chat-compose-send blue-button')[0].click();
}, 6000);
setTimeout(function lkqqs() {
document.getElementsByClassName('messenger-contact-list-contacts-item-remove')[0].click();
}, 8000);
setTimeout(function lkqaqs() {
document.getElementsByClassName('blue-button confirm-popup-confirm')[0].click();
}, 10000);
setTimeout(function lkeqq() {
document.getElementsByClassName('messenger-contact-list-contacts-more')[0].click();
}, 12000);
setTimeout(function lkqsq() {
location.reload();
}, 14000);
}, 17000);
})();
} else {setInterval(function() {
document.getElementsByClassName('standard_star blue-button dating-button-sympathy dating-button-common')[0].click();
}, 5000);}
}, 30000);
})(0);
//setTimeout (function lk(){like[0].click();},1000);
})();
//var i;
// setInterval(function() {
//setTimeout (function (){document.getElementsByClassName('blue-button press-message')[i].click();},2000); ++i;) })();
// },2000);