I want to create a Google Chrome extension that, among other things, will change the chat text based on the input. I will add a button next to the video, call and add the buttons of people under the name, and when I click, it will activate the changes. I don’t want to put more scripts on the page than I need, so I would like to be able to send messages the way Gmail will click “return” in the chat window. In addition, I want to show that both people in the chat use my extension by displaying the text in the chat window, just like the text “This chat is disconnected from recording”, and maybe if both use it, add extra material to chat. What I tried to do was create a simulated text area, and when the user "sends" it, take it and change it, and then paste it into the real one and send the new text.I can change the text, but I can not send it ...
Here is what I have so far, I put everything in setInterval to check if the chat window exists and add the appropriate material to it:
var chatBtnClone = setInterval(function() {
if ($("body").find(".nH .NG").length > 0) {
var clone = $("body").find(".nH .NG .NJ").first();
if (clone.children()[0].className.indexOf("chat") < 0) {
var clonned = clone.clone();
var clonnedChd = clonned.children().first();
clonnedChd.attr("title", "Start encrypted chat");
clonnedChd.on('click', function() {
console.log("clicked chatBtn!");
var self = $(this);
if (self[0].className.indexOf("chatEncX") >= 0) {
self.removeClass('chatEncX').addClass('chatEnc');
self.attr("title", "Stop encrypted chat");
} else {
self.removeClass('chatEnc').addClass('chatEncX');
self.attr("title", "Start encrypted chat");
}
});
clone.parent().prepend(clonned);
clonned.find('.NK').removeClass("NK-Y8").addClass("chatEncX");
}
var chatBoxs = $('body').find(".nn .AD");
var chatArea = chatBoxs.first().find(".nH textarea");
if (chatArea.length === 1) {
var clonChatArea = chatArea.first().clone();
clonChatArea.removeAttr("id");
chatArea.first().parent().append(clonChatArea);
var chatTextDiv = chatBoxs.first().find(".jp .nH .nH").first();
clonChatArea.focusin(function() {
chatTextDiv.removeClass("gv").addClass("f7");
});
clonChatArea.focusout(function() {
chatTextDiv.removeClass("f7").addClass("gv");
});
clonChatArea.on('keyup', function(event) {
var self = this;
if (self.scrollHeight === 38) {
self.style.overflowY = "hidden";
self.style.height = "36px";
} else if (self.scrollHeight === 47) {
self.style.height = "54px";
} else if (self.scrollHeight === 62) {
self.style.height = "72px";
} else if (self.scrollHeight >= 77) {
self.style.height = "80px";
self.style.overflowY = "scroll";
}
if( event.keyCode === 13 && event.shiftKey ){
} else if (event.keyCode === 13) {
var chatTxt = $(this).val();
var chatHidden = chatBoxs.first().find(".nH textarea").first();
var chatEncTxt = Crypto.AES.encrypt(chatTxt, "pass");
chatHidden.val(chatEncTxt);
chatHidden.focus();
chatHidden.trigger({ type : 'keypress', which : 13 });
}
});
}
}
},150);
source
share