Created
May 30, 2014 13:50
-
-
Save franklinjavier/d5640d7680eb389abed8 to your computer and use it in GitHub Desktop.
Print out data URLs for all images / canvases on the page.
This file contains hidden or 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
http://h.com/index.html