Created
November 2, 2016 15:01
-
-
Save skew202/bec69009a2af660be62d553379fe3cea 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
// dataurl.js | |
// https://github.com/bgrins/devtools-snippets | |
// Print out data URLs for all images / canvases on the page. | |
(function() { | |
console.group("Data URLs"); | |
[].forEach.call(document.querySelectorAll("img"), function(i) { | |
var c = document.createElement("canvas"); | |
var ctx = c.getContext("2d"); | |
c.width = i.width; | |
c.height = i.height; | |
try { | |
ctx.drawImage(i, 0, 0); | |
console.log(i, c.toDataURL()); | |
} | |
catch(e) { | |
console.log(i, "No Permission - try opening this image in a new tab and running the snippet again?", i.src); | |
} | |
}); | |
[].forEach.call(document.querySelectorAll("canvas"), function(c) { | |
try { | |
console.log(c, c.toDataURL()); | |
} | |
catch(e) { | |
console.log(c, "No Permission"); | |
} | |
}); | |
console.groupEnd("Data URLs"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment