您的问题有更简单的(与提供的相比)解决方案,但它需要一些服务器端代码(最后解释)。因此,JS 将如下所示:
$("img").each(function()
{
// Check each target image and try to resolve its src
$.ajax(
{
url: $(this)[0].src,
type: "get",
context: $(this),
error: function()
{
// Delete on error (404)
$(this).remove();
console.log("ERR!");
},
success: function(data)
{
// It's OK!
console.log("YEAH!");
}
});
});
因为不允许跨域请求,所以您需要编写简单的代理脚本,将图像内容传递到您的服务器。
例如:yoursite.com/imageproxy?src=http://p.twimg.com/Axm3Vs-CQAEwfAj.jpg:large返回http://p.twimg.com/Axm3Vs-CQAEwfAj.jpg:large带有原始标题的图像内容。
更新:
作为对@Fresheyeball 答案的评论的说明:

更新 2:
另外,我认为您可以尝试使用Brain.js来训练神经网络,这可以帮助您稍后与颜色进行比较。但...
也许为图像编写 4 字符串代理更容易(当然,如果有无限带宽)。