TheFabulousPika / steam-chatlog-to-text

A chrome extension that converts Steam webchat log to text format
2 stars 0 forks source link

Fix: Group chat conversion not working #16

Closed TheFabulousPika closed 4 years ago

TheFabulousPika commented 4 years ago

Group chat conversion does not work

TheFabulousPika commented 4 years ago

original code

function findChatFriendName() {
    var activeTabIndex = findActiveTabIndex();
    var activeChatBody = document.getElementsByClassName("DropTarget chatWindow MultiUserChat")[activeTabIndex];
    var friendName = activeChatBody.getElementsByClassName("FriendChatTypingNotification")[0].innerText.split(" is typing a message...")[0];
    return friendName;
}

fix

function findChatRoomName() {
    var activeTabIndex = findActiveTabIndex();
    var activeChatBody = document.getElementsByClassName("DropTarget chatWindow MultiUserChat")[activeTabIndex];
    if (activeChatBody.getElementsByClassName("FriendChatTypingNotification").length > 0){
        var friendName = activeChatBody.getElementsByClassName("FriendChatTypingNotification")[0].innerText.split(" is typing a message...")[0];
        return friendName;
    }
    else {
    return activeChatBody.getElementsByClassName("chatRoomGroupHeaderName")[0].innerHTML;
    }
}

function and parameter names changed to chatRoomName from friendName

TheFabulousPika commented 4 years ago

New function added to process server messages (people entering and leaving group chat room)

function msgserverMsg(a){
    var serverMsg =  '<span class="serverMsg">' + a.innerText +  '</span><br />';
    return serverMsg;
}