简体   繁体   中英

Overwrite facebook Function called when we send message on chat

I want to overwrite facebook function called when we press enter to send message on chat.

This is the class "uiTextareaAutogrow _552m". I want to get message encrypted before sending. I am trying for hours but can't find the solution

the best I got so far

var o = document.getElementsByClassName("uiTextareaAutogrow _552m");

o[0].onkeypress=function(e){ 

if(e.charCode=="13"){

       encrypt();

   } };

but what is happening that this and facebook function is executing simultaneously so the message is delivered without encryption.

Please help me in finding the facebook function.

You will not be able to do this successfully for several reasons, the primary one being that you have no stable means of identifying which element to attach your listeners to - that class name is autogenerated and will change randomly.

Secondly, as you've discovered, you have no way of ensuring that your event handler executes first, nor any reliable way of altering the value which other even handlers might be operating on - what's being sent might very well be the value after the previous keyUp event, and not the one before the current enter event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM