Skip to content

Instantly share code, notes, and snippets.

@aont
Last active December 14, 2023 13:55
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/f805412aacc061b10b95c0d18158ea78 to your computer and use it in GitHub Desktop.
Save aont/f805412aacc061b10b95c0d18158ea78 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) {
var anchor = img.parentElement;
anchor.removeAttribute("href")
// console.log(img)
var canvas = document.createElement("canvas")
canvas.height = img.naturalHeight
canvas.width = img.naturalWidth
canvas.style.maxWidth = "100%"
var context = canvas.getContext("2d")
context.drawImage(img, 0, 0)
anchor.appendChild(canvas)
anchor.removeChild(img)
}
})
javascript:Array.from(document.querySelectorAll('img[src^="https://private-user-images.githubusercontent.com/"]')).forEach((img,index,array)=>{if(img.complete){var anchor=img.parentElement;anchor.removeAttribute("href");var canvas=document.createElement("canvas"),context;canvas.height=img.naturalHeight,canvas.width=img.naturalWidth,canvas.style.maxWidth="100%",canvas.getContext("2d").drawImage(img,0,0),anchor.appendChild(canvas),anchor.removeChild(img)}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment