@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)

comments (single view)

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);
};
View all comments