Created
December 14, 2023 14:27
-
-
Save aont/d05f386164041905129389619ee92683 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.from(document.querySelectorAll("img[src^=\"https://private-user-images.githubusercontent.com/\"]")).forEach((img, index, array)=>{ | |
if(!img.complete) { | |
let imgSrc = img.src; | |
img.src = ""; | |
img.style.display = "none"; | |
// img.setAttribute("_src", imgSrc) | |
let anchor = img.parentElement; | |
// anchor.removeChild(img); | |
let textNode = document.createTextNode("click to view image"); | |
anchor.appendChild(textNode) | |
anchor.setAttribute("href", "#") | |
anchor.onclick = (event)=>{ | |
anchor.removeChild(textNode) | |
img.src = imgSrc; | |
img.style.display = ""; | |
anchor.onclick = null; | |
anchor.removeAttribute("href") | |
return false; | |
}; | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:Array.from(document.querySelectorAll('img[src^="https://private-user-images.githubusercontent.com/"]')).forEach((img,index,array)=>{if(!img.complete){let imgSrc=img.src;img.src="",img.style.display="none";let anchor=img.parentElement,textNode=document.createTextNode("click to view image");anchor.appendChild(textNode),anchor.setAttribute("href","#"),anchor.onclick=event=>(anchor.removeChild(textNode),img.src=imgSrc,img.style.display="",anchor.onclick=null,anchor.removeAttribute("href"),!1)}}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment