Skip to content

Instantly share code, notes, and snippets.

@davrous
Created November 24, 2016 18:04
Show Gist options
  • Save davrous/b6436e796fe94978b76217299e32b25a to your computer and use it in GitHub Desktop.
Save davrous/b6436e796fe94978b76217299e32b25a to your computer and use it in GitHub Desktop.
console.log("Dare Angel content script started");
browser.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.command == "requestImages") {
var images = document.getElementsByTagName('img');
var imagesList = [];
for (var i = 0; i < images.length; i++) {
if ((images[i].src.toLowerCase().endsWith(".jpg") || images[i].src.toLowerCase().endsWith(".png"))
&& (images[i].width > 64 && images[i].height > 64)) {
imagesList.push({ url: images[i].src, alt: images[i].alt });
}
}
sendResponse(JSON.stringify(imagesList));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment