TheFabulousPika / steam-chatlog-to-text

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

Enhancement: Add missing alt text to emoticon #54

Closed TheFabulousPika closed 3 years ago

TheFabulousPika commented 3 years ago

Emoticon alt text is missing in the original chat. This is an issue on Steam's end.

<img src="https://community.cloudflare.steamstatic.com/economy/emoticonlarge/winter2019tiredyul" class="emoticon_emoticon_9hYGN emoticon_large_p8Q42" data-emoticon="winter2019tiredyul" data-copystyle="merge-adjacent" data-copytext=":winter2019tiredyul:">

Add feature to extension that adds alt text

TheFabulousPika commented 3 years ago
function addAltTextToEmoticons(a){
    var thisMsgNode = a;
    var allEmoticons = thisMsgNode.querySelectorAll('[class*=emoticon_emoticon]');
    for (var i = 0; i < allEmoticons.length; i++){
        var thisEmoticon = allEmoticons[i];
        var altText = document.createAttribute("alt");
        altText.value = thisEmoticon.getAttributeNode("data-copytext").value;
        thisEmoticon.setAttributeNode(altText);
    }
    return thisMsgNode;
}
function cleanupMsg(a){
    var thisMsgNode = a;
    var cleanedMsgText = '';
    thisMsgNode = addAltTextToEmoticons(thisMsgNode);
...