TheFabulousPika / steam-chatlog-to-text

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

Fix: /code formatting. Remove extra linebreaks #12

Closed TheFabulousPika closed 4 years ago

TheFabulousPika commented 4 years ago

/code test is converted with extra linebreaks

TheFabulousPika commented 4 years ago

Current check isn't working. Class name is no longer used to differentiate this type of chat message.

function checkIfCode(a){
    var thisMsgNode = a;
    var parentClass = thisMsgNode.parentNode.className;
    var evalPatt = new RegExp("ChatMsgSlashCode");
    return evalPatt.test(parentClass);
}

<div class="msg isCurrentUser">
    <div class="msgText " data-copytext="">
        <div>
            <pre class="prettyprint messages_CodeMessage_1Fe4I prettyprinted" style="">
                <span class="kwd">function</span>
                <span class="pln"> foo </span>
                <span class="pun">{</span>
                <span class="pln"> </span>
                <span class="kwd">do</span>
                <span class="pln"> something </span>
                <span class="pun">};</span>
            </pre>
        </div>
    </div>
</div>
TheFabulousPika commented 4 years ago

Look for the magic word "CodeMessage" in class

function checkIfCode(a){
    var thisMsgNode = a;
    var codeOrNot= thisMsgNode.querySelectorAll('[class*=CodeMessage]').length;
    if (codeOrNot == 0){
    return false;
    }
    else {
    return true;
    }
}
TheFabulousPika commented 4 years ago

Fixed