HappyDestroy / JVC On Facebook

// ==UserScript==
// @name         JVC On Facebook
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Ajoute les smileys JVC dans le chat Facebook
// @author       HappyDestroy
// @match        https://www.facebook.com/*
// @require		 http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @grant        none
// ==/UserScript==

$(document).ready(function() {

    $('._1ia').bind('DOMSubtreeModified', reBind);

    loadSmiley();
});


function reBind() {
    $('._1ia').unbind('DOMSubtreeModified');
    if($(this).find('._5yl5 > span').length && $(this).find('._5yl5 > span').last().html() !== '') {
        $(this).find('._5yl5 > span').last().html(replace($(this).find('._5yl5 > span').last().html()));
    }
    $('._1ia').bind('DOMSubtreeModified', reBind);
}


function loadSmiley() {

    $('._4tdv ._5yl5 span').each(function() {
        if($(this).html() !== '') {
            $(this).html(replace($(this).html()));
        }
    });

}


function replace(myText) {
    myText = myText.replace(new RegExp(':hap:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/18.gif"/>');
    myText = myText.replace(new RegExp(':noel:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/11.gif"/>');
    myText = myText.replace(new RegExp(':cool:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/26.gif"/>');
    myText = myText.replace(new RegExp(':snif:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/20.gif"/>');
    myText = myText.replace(new RegExp(':snif2:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/13.gif"/>');
    myText = myText.replace(new RegExp(':ouch:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/22.gif"/>');
    myText = myText.replace(new RegExp(':ouch2:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/57.gif"/>');
    myText = myText.replace(new RegExp(':oui:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/37.gif"/>');
    myText = myText.replace(new RegExp(':ok:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/36.gif"/>');
    myText = myText.replace(new RegExp(':sournois:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/67.gif"/>');
    myText = myText.replace(new RegExp(':coeur:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/54.gif"/>');
    myText = myText.replace(new RegExp(':fou:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/50.gif"/>');
    myText = myText.replace(new RegExp(':rire:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/39.gif"/>');
    myText = myText.replace(new RegExp(':malade:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/8.gif"/>');
    myText = myText.replace(new RegExp(':non:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/35.gif"/>');
    myText = myText.replace(new RegExp(':angry:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/15.gif"/>');
    myText = myText.replace(new RegExp(':doute:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/45.gif"/>');
    myText = myText.replace(new RegExp(':peur:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/47.gif"/>');
    myText = myText.replace(new RegExp(':bave:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/71.gif"/>');
    myText = myText.replace(new RegExp(':pf:', 'g'), '<img src="https://image.jeuxvideo.com/smileys_img/pf.gif"/>');

    return myText;
}