I'm building a Chrome Extension to replace the current chat's input box with the music I'm currently listening to by the press of "´". Please keep in mind that like in the actual desktop version of Facebook, there is no input/textarea tag element and it's made with react.
I'm stuck at properly replacing the text in the private Facebook-Clone's input, I can see it there, but when I press Enter, it doesn't send.
Screencast of what happens at the moment: https://vimeo.com/203014549
This private Facebook-Clone works exactly like the actual desktop version of Facebook in regards to the Chat.
content.js:
$(function() {
if (window.jQuery) {
$('body').append("<div class='facemusic_tip' style='position:fixed;min-width:400px;width:400px;min-height:20px;height:20px;overflow:scroll;background-color:#000000;top:0;left:0;padding:10px;z-index:99999;color:white'>Press ´ in your message input to inject current song</div>");
function findAncestor(el, cls) {
while ((el = el.parentElement) && !el.classList.contains(cls));
return el;
}
$(document).on("keydown", function(e) {
if(e.which === 229){
var currentmusic = getCurrentMusicAsString();
keytarget = findAncestor(e.target, 'fbNubFlyoutOuter');
var $chatbox_outer = $(keytarget);
$chatbox_outer.parent('.fbDockChatTabFlyout.uiContextualLayerParent').find("._5rpu").html("I'm listening to: "+currentmusic);
}
});
};
});
UPDATE:
It seems to be something about react that I don't quite understand, because on enter it just gets replaced with the characters populated by manual keystroke and my manipulated version of the input field is gone, see video for bug.