document body style min height 300px const items await navigator clipboard read const textBlob await items 0 getType text plain const text await new Response textBlob text async function dopaste console log dopaste const items await navigator clipboard read console log num paste items items length for let i 0 i items length i let item items i let type await items i getType text plain console log item type type for let type of item types console log type type if type text plain const textBlob await items i getType text plain const textUrl await new Response textBlob text console log text textUrl if textUrl indexOf https 0 textUrl indexOf textUrl 0 console log valid http address const response await fetch textUrl const imageBlob await response blob const reader new FileReader reader readAsDataURL imageBlob reader onloadend const base64data reader result console log base64data let img document createElement img img width img height 200 img src base64data document body appendChild img else console log not url for image does not start with http else if type image png raw image const blobOutput await items i getType image png var imageBlob items i getAsFile const reader new FileReader reader readAsDataURL blobOutput reader onloadend const base64data reader result console log base64data let img document createElement img img width img height 200 img src base64data document body appendChild img console log adding image let button document createElement button document body appendChild button button innerHTML Paste button onclick dopaste console log ready
og base64data let img document createElement img img width img height 200 img src base64data document body appendChild img else console log not url for image does not start with http else if type image png raw image const blobOutput await items i getType image png var imageBlob items i getAsFile const reader new FileReader reader readAsDataURL blobOutput reader onloadend const base64data reader result console log base64data let img document createElement img img width img height 200 img src base64data document body appendChild img console log adding image let button document createElement button document body appendChild button button innerHTML Paste button onclick dopaste console log ready