I don’t know javascript so I can not provide any advice on how to extract from your javascript the actual QR code. There are free plugins available that create QR codes that work well and make it simple to save the QR code image.