Created
July 29, 2014 19:29
-
-
Save nathan/74a6dc1e5b26093f10db to your computer and use it in GitHub Desktop.
Find broken PNG assets in a project.
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
var all = document.body.innerText.match(/\w{32}\.png/g); | |
var broken = []; | |
all.forEach(function(a) { | |
var xhr = new XMLHttpRequest; | |
xhr.open('GET', 'http://cdn.scratch.mit.edu/internalapi/asset/'+a+'/get/', false); | |
xhr.send(); | |
if (/^<svg/.test(xhr.responseText)) { | |
broken.push(a); | |
console.log('http://cdn.scratch.mit.edu/internalapi/asset/'+a+'/get/'); | |
} | |
}); | |
copy(broken.map(function(a) {return '- ['+a+'](http://cdn.scratch.mit.edu/internalapi/asset/'+a+'/get/)'}).join('\n')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment