potoooooooo ✅️@lemmy.world to Lemmy Shitpost@lemmy.worldEnglish · 1 day agoThis is what they took from us.lemmy.worldimagemessage-square137fedilinkarrow-up1356arrow-down115
arrow-up1341arrow-down1imageThis is what they took from us.lemmy.worldpotoooooooo ✅️@lemmy.world to Lemmy Shitpost@lemmy.worldEnglish · 1 day agomessage-square137fedilink
minus-squaremeekah@discuss.tchncs.delinkfedilinkarrow-up5·edit-29 hours agopro-tip: putting image URLs in your comment like this:  makes the image show up in your comment rather than just the URL I ended up making a quick tampermonkey script to convert image links to image elements this probably needs some work on the isImageUrl function but it works for this instance at least haha (function() { Array.from(document.querySelectorAll('a')).filter(e => isImageUrl(e.href)).forEach(imageLink => { var imageElement = document.createElement('img'); imageElement.src = imageLink.href; imageLink.after(imageElement); imageLink.style.display = 'none' }); })(); function isImageUrl(input){ var url = new URL(input.toLowerCase()); return url.pathname.endsWith('.jpg') || url.pathname.endsWith('.png') || url.pathname.endsWith('.gif'); } oh and I guess it needs to be re-executed for when more comments are loaded by scrolling. in that case the already created image elements would double up, but you could just delete the original image link… it is quick and dirty after all edit: V2 is here (function() { console.log('script loaded'); setInterval(findAndReplaceImageLinks, 10); })(); function findAndReplaceImageLinks(){ Array.from(document.querySelectorAll('a')).filter(e => isImageUrl(e.href)).forEach(imageLink => { if (imageLink.classList == 'fst-italic link-dark link-opacity-75 link-opacity-100-hover'){ return; } //console.log(imageLink) var imageElement = document.createElement('img'); imageElement.src = imageLink.href; imageLink.after(imageElement); imageLink.remove(); console.log('image replaced'); }); } function isImageUrl(input){ var url = new URL(input.toLowerCase()); return url.pathname.endsWith('.jpg') || url.pathname.endsWith('.png') || url.pathname.endsWith('.gif'); }
pro-tip: putting image URLs in your comment like this:
makes the image show up in your comment rather than just the URLI ended up making a quick tampermonkey script to convert image links to image elements
this probably needs some work on the
isImageUrlfunction but it works for this instance at least haha(function() { Array.from(document.querySelectorAll('a')).filter(e => isImageUrl(e.href)).forEach(imageLink => { var imageElement = document.createElement('img'); imageElement.src = imageLink.href; imageLink.after(imageElement); imageLink.style.display = 'none' }); })(); function isImageUrl(input){ var url = new URL(input.toLowerCase()); return url.pathname.endsWith('.jpg') || url.pathname.endsWith('.png') || url.pathname.endsWith('.gif'); }oh and I guess it needs to be re-executed for when more comments are loaded by scrolling. in that case the already created image elements would double up, but you could just delete the original image link… it is quick and dirty after all
edit: V2 is here
(function() { console.log('script loaded'); setInterval(findAndReplaceImageLinks, 10); })(); function findAndReplaceImageLinks(){ Array.from(document.querySelectorAll('a')).filter(e => isImageUrl(e.href)).forEach(imageLink => { if (imageLink.classList == 'fst-italic link-dark link-opacity-75 link-opacity-100-hover'){ return; } //console.log(imageLink) var imageElement = document.createElement('img'); imageElement.src = imageLink.href; imageLink.after(imageElement); imageLink.remove(); console.log('image replaced'); }); } function isImageUrl(input){ var url = new URL(input.toLowerCase()); return url.pathname.endsWith('.jpg') || url.pathname.endsWith('.png') || url.pathname.endsWith('.gif'); }