Closed TheFabulousPika closed 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>
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;
}
}
Fixed
/code test is converted with extra linebreaks