mercredi 21 septembre 2016

Cannot read property 'focus' of undefined

This dispatch code was working perfectly until an update on the web whatsapp page, I would like a help to know how to fix it

function dispatch(target, eventType, msg) {
        var evt = document.createEvent("TextEvent");
        evt.initTextEvent (eventType, true, true, null, msg, 0, "en-US");
        target.focus();
        target.dispatchEvent(evt);
    }

And Spam function

function spam(msg) {
    var texto = msg;
    var campo = document.getElementsByClassName('input-emoji')[1];
    dispatch(campo, 'textInput', texto);
    var input = document.getElementsByClassName('icon btn-icon icon-send send-container');
    input[0].click();
    setTimeout(function() {}, 50);
}

This is the error of the console

Uncaught TypeError: Cannot read property 'focus' of undefined VM2174:20357 
dispatch @ VM2174:20357
spam @ VM2174:20376
(anonymous function) @ VM2174:20364
(anonymous function) @ VM2160:2
e.string.c.(anonymous function) @ VM2171:52

thanks in advance




Aucun commentaire:

Enregistrer un commentaire