cst1229 @cst1229

@jeffalo how did you detect the origin of a pasted image (it only works from cubeupload or imgbb. i thought copied images only include the image data)

Nov 7, 2021, 4:39 PM
2
View all Parent

comments

Highlighted comment

apparently event data transfers have that data. like this code (pasted from stackoverflow):

target.onpaste = (e) => {
  const dT = e.clipboardData || window.clipboardData;
  const html = dT.getData('text/html') || "";
  const parsed = new DOMParser().parseFromString(html, 'text/html');
  const img = parsed.querySelector('img');
  if( !img ) { console.warn('no image here'); return; }
  const url = img.src;
  console.log(url);
};