Skip to content

Instantly share code, notes, and snippets.

@aont
Created December 14, 2023 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aont/d05f386164041905129389619ee92683 to your computer and use it in GitHub Desktop.
Save aont/d05f386164041905129389619ee92683 to your computer and use it in GitHub Desktop.
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;
};
}
})
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