TheFabulousPika / steam-chatlog-to-text

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

Steam Guide Sign In required embedded link #38

Closed TheFabulousPika closed 4 years ago

TheFabulousPika commented 4 years ago

<div class="msgText " data-copytext=""><span data-copytext="" data-copystyle="merge-adjacent" bbcode-text=":s ">:s </span>
  <div class="ChatMessageOpenGraph" data-copystyle="block" data-copytext="Sign In
https://steamcommunity.com/profiles/76561198047562689/home/">
    <div class="OpenGraphContent">
      <div class="OpenGraphImgBackground"><img class="ChatMessageOpenGraph_Image" src="https://steamcommunity-a.akamaihd.net/chat/image/1917EA4gVRr3m6Gu2aDdRqfSWjapH72sX-wDX6xP7NDjXZZPfwYvBW1Sus-HC611Q-Sh80o0vkwl6GijPug0sGQmynNOgYduad0FhuuUJGLIwPZJgsAuI573A0T1IluYZXgTRg/share_image.png"></div><a class="OpenGraphImgContainer" href="https://steamcommunity.com/profiles/76561198047562689/home/"><img class="ChatMessageOpenGraph_Image" src="https://steamcommunity-a.akamaihd.net/chat/image/1917EA4gVRr3m6Gu2aDdRqfSWjapH72sX-wDX6xP7NDjXZZPfwYvBW1Sus-HC611Q-Sh80o0vkwl6GijPug0sGQmynNOgYduad0FhuuUJGLIwPZJgsAuI573A0T1IluYZXgTRg/share_image.png?s=256x140" srcset="https://steamcommunity-a.akamaihd.net/chat/image/1917EA4gVRr3m6Gu2aDdRqfSWjapH72sX-wDX6xP7NDjXZZPfwYvBW1Sus-HC611Q-Sh80o0vkwl6GijPug0sGQmynNOgYduad0FhuuUJGLIwPZJgsAuI573A0T1IluYZXgTRg/share_image.png?s=256x140 1x, https://steamcommunity-a.akamaihd.net/chat/image/1917EA4gVRr3m6Gu2aDdRqfSWjapH72sX-wDX6xP7NDjXZZPfwYvBW1Sus-HC611Q-Sh80o0vkwl6GijPug0sGQmynNOgYduad0FhuuUJGLIwPZJgsAuI573A0T1IluYZXgTRg/share_image.png?s=256x140dpx2x 2x"></a>
      <div class="ChatMessageOpenGraph_Body"><a class="ChatMessageOpenGraph_Title" href="https://steamcommunity.com/profiles/76561198047562689/home/">Sign In</a></div>
      <div style="clear: left;"></div>
    </div>
    <div class="OpenGraphFooter">
      <div class="OpenGraphMessageURL"><span class="OpenGraphMessageURLPosition"><span class="OpenGraphMessageURL_short">steamcommunity.com</span><input class="OpenGraphMessageURL_full" readonly="" value="https://steamcommunity.com/profiles/76561198047562689/home/"></span></div>
      <div class="OpenGraphURLButton CopyToClipboard" title="Copy Link to Clipboard"><svg version="1.1" class="SVGIcon_Button SVGIcon_CopyToClipboard" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="256px" height="256px" viewBox="0 0 256 256">
          <polyline fill="none" class="line" stroke-width="12" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="178.25,197.25 247,197.25 247,82.5 175,10.25 111.5,10.25 111.5,56 "></polyline>
          <polygon fill="none" class="line" stroke-width="12" stroke-linejoin="round" stroke-miterlimit="10" points="155,133 83,60.75 11,60.75 11,247.75 155,247.75 "></polygon>
          <polyline fill="none" class="line" stroke-width="12" stroke-linejoin="round" stroke-miterlimit="10" points="83,60.75 83,133 155,133 "></polyline>
          <polyline fill="none" class="line" stroke-width="12" stroke-linejoin="round" stroke-miterlimit="10" points="175,10.25 175,82.5 247,82.5 "></polyline>
        </svg></div>
    </div>
  </div>
</div>
TheFabulousPika commented 4 years ago

Ordinary Graph

<div class="msgText " data-copytext="">
  <div class="ChatMessageOpenGraph" data-copystyle="block" data-copytext="Steam Community :: Group :: Broadcast Windows Games
A casual group for people who like broadcasting preloaded Windows games such as Minesweeper, FreeCell, Solitaire, MahJong, etc.
https://steamcommunity.com/groups/BroadcastWindowsGames">
    <div class="OpenGraphContent">
      <div class="OpenGraphImgBackground"><img class="ChatMessageOpenGraph_Image" src="https://steamcommunity-a.akamaihd.net/chat/image/4EIH0R7GqQJrfzDFJIBMPGWWareRUqaCMD5gXTZQcRbgCPD_NmctUqp7NwnnCu92YuVoXp58cgEAh67FS1ZbdAmWUI1K-jFjJgS2FxQiHb91k__PxcakCJTACZRyUPnDg8NuUgsjiebhdpoNMQcG-QJnOtcQq995z8RiwA/share_image.jpg"></div><a class="OpenGraphImgContainer" href="https://steamcommunity.com/groups/BroadcastWindowsGames"><img class="ChatMessageOpenGraph_Image" src="https://steamcommunity-a.akamaihd.net/chat/image/4EIH0R7GqQJrfzDFJIBMPGWWareRUqaCMD5gXTZQcRbgCPD_NmctUqp7NwnnCu92YuVoXp58cgEAh67FS1ZbdAmWUI1K-jFjJgS2FxQiHb91k__PxcakCJTACZRyUPnDg8NuUgsjiebhdpoNMQcG-QJnOtcQq995z8RiwA/share_image.jpg?s=256x140" srcset="https://steamcommunity-a.akamaihd.net/chat/image/4EIH0R7GqQJrfzDFJIBMPGWWareRUqaCMD5gXTZQcRbgCPD_NmctUqp7NwnnCu92YuVoXp58cgEAh67FS1ZbdAmWUI1K-jFjJgS2FxQiHb91k__PxcakCJTACZRyUPnDg8NuUgsjiebhdpoNMQcG-QJnOtcQq995z8RiwA/share_image.jpg?s=256x140 1x, https://steamcommunity-a.akamaihd.net/chat/image/4EIH0R7GqQJrfzDFJIBMPGWWareRUqaCMD5gXTZQcRbgCPD_NmctUqp7NwnnCu92YuVoXp58cgEAh67FS1ZbdAmWUI1K-jFjJgS2FxQiHb91k__PxcakCJTACZRyUPnDg8NuUgsjiebhdpoNMQcG-QJnOtcQq995z8RiwA/share_image.jpg?s=256x140dpx2x 2x"></a>
      <div class="ChatMessageOpenGraph_Body"><a class="ChatMessageOpenGraph_Title" href="https://steamcommunity.com/groups/BroadcastWindowsGames">Steam Community :: Group :: Broadcast Windows Games</a>
        <div class="ChatMessageOpenGraph_Description">A casual group for people who like broadcasting preloaded Windows games such as Minesweeper, FreeCell, Solitaire, MahJong, etc.</div>
      </div>
      <div style="clear: left;"></div>
    </div>
    <div class="OpenGraphFooter">
      <div class="OpenGraphMessageURL"><span class="OpenGraphMessageURLPosition"><span class="OpenGraphMessageURL_short">steamcommunity.com</span><input class="OpenGraphMessageURL_full" readonly="" value="https://steamcommunity.com/groups/BroadcastWindowsGames"></span></div>
      <div class="OpenGraphURLButton CopyToClipboard" title="Copy Link to Clipboard"><svg version="1.1" class="SVGIcon_Button SVGIcon_CopyToClipboard" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="256px" height="256px" viewBox="0 0 256 256">
          <polyline fill="none" class="line" stroke-width="12" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="178.25,197.25 247,197.25 247,82.5 175,10.25 111.5,10.25 111.5,56 "></polyline>
          <polygon fill="none" class="line" stroke-width="12" stroke-linejoin="round" stroke-miterlimit="10" points="155,133 83,60.75 11,60.75 11,247.75 155,247.75 "></polygon>
          <polyline fill="none" class="line" stroke-width="12" stroke-linejoin="round" stroke-miterlimit="10" points="83,60.75 83,133 155,133 "></polyline>
          <polyline fill="none" class="line" stroke-width="12" stroke-linejoin="round" stroke-miterlimit="10" points="175,10.25 175,82.5 247,82.5 "></polyline>
        </svg></div>
    </div>
  </div>
</div>

current detection code

function checkIfGraph(a){
    var thisMsgNode = a;
    if (thisMsgNode.children.length < 1){
    return false;
    }
    else {
    var childClass = thisMsgNode.children[0].className;
    var evalPatt = new RegExp("ChatMessageOpenGraph");
    return evalPatt.test(childClass);
    }
}

current formatting


    else if (checkIfGraph(thisMsgNode)) {
    var graphURL = thisMsgNode.getElementsByClassName("ChatMessageOpenGraph_Title")[0].href;
    var graphTitle = thisMsgNode.getElementsByClassName("ChatMessageOpenGraph_Title")[0].innerText;
    cleanedMsgText = linkefyURL(graphURL) + '<br />' + graphTitle;
    }