简体   繁体   中英

Javascript converts img src to invalid base64

I try to retrieve profile icons from web.whatsapp.com. The source code explorer as well as with javascript retrieved img node shows me a regular static link to the image I want to get (https:....)

Image tag retrieved with javascript

Retrieving the correct src should be a trivial task but no matter if I use

image.src or image.getAttribute('src')

I always end up with the same base64 string for what ever picture I try to fetch. How do I extract the src of the image tag without it being converted into gibberish?

Result of the image.src

This was done using tampermonkey on google chrome on a mac.

Edit: Additional info as per request:

<img src="https://dyn.web.whatsapp.com/pp?t=s&amp;u=4915786584978%40c.us&amp;i=1484932082&amp;ref=1%40%2FOBUmUFr2127pJ5jnyNl9BylFIWp6h2FiEm475nQg0gtYw%2FSf7tuwfp9&amp;tok=1%4016ljMAEqnFIwx%2FcEvV4mq6VdicCO59U5CXvI%2FDlEBR09UnXl5bHnAXdEBO3r3zPVMNP7W4g2BWMmNw%3D%3D" draggable="false" class="avatar-image is-loaded">

The base64 string does not start with an ';'. This was just part of my console debug. The plain content is shown below.

data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7

It appeared that even though the javascript script waited for the execution until the image dom objects were created the src was not set yet. A small delay in the execution solved the issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM