window.addEventListener("load", monospaceInit, false);
var messangerwindow = document.getElementById("webMessengerRecentMessages");
function monospaceInit(evt) {
    detect(evt);
    messangerwindow.addEventListener('DOMNodeInserted', detect, false);
}

function detect(evt) {

    console.log("bye");
    //characters for codeblock
    var start = "`~ ";
    var stop = " ~`";

    //main chat only. small chat splits lines into seperate elements...
    var chat = messangerwindow.getElementsByClassName("_38"); //what is the exact meanning of _38???
    for (i = 0; i < chat.length; i++) {
        text = chat[i].getElementsByTagName("p")[0];
        // console.log( text );
        words = chat[i].innerText;
        // console.log(words + "contains lol? : " + words.indexOf( "lol" ) );
        var stop_index = words.indexOf(stop);
        var start_index = words.indexOf(start);
        if (stop_index > start_index && start_index > -1) {
            text.className += " code";
            text.innerText = words.substr(start_index + 3, stop_index - start_index - 3);
        }
    }
}

monospaceInit();

function monospaceInit() {
    window.msgWindow = document.getElementById("webMessengerRecentMessages");
    detect();
    msgWindow.addEventListener('DOMNodeInserted', detect, false);
}

function detect() {

    //characters for codeblock
    var start = "`~ ";
    var stop = " ~`";

    //main chat only. small chat splits lines into seperate elements...
    var chat = msgWindow.getElementsByClassName("_38"); //what is the exact meanning of _38???
    for (i = 0; i < chat.length; i++) {
        text = chat[i].getElementsByTagName("p")[0];
        // console.log( text );
        words = chat[i].innerText;
        // console.log(words + "contains lol? : " + words.indexOf( "lol" ) );
        var stop_index = words.indexOf(stop);
        var start_index = words.indexOf(start);
        if (stop_index > start_index && start_index > -1) {
            text.className += " code";
            text.innerText = words.substr(start_index + 3, stop_index - start_index - 3);
        }
    }
}

remove onload event for chrome, name fix