I'm trying to make a snippet of javascript that can get a list of all images (or other resources) that are used in a web page because they are referenced in the css. Typically they are background images, because somewhere in the css there is something like this:
.something {
background: transparent url(images/somethingbg.png) no-repeat top left;
}
It seems I can get all of these into an array (with their full path) with the following snippet:
var outputArray = [];
var string = "";
var elems = document.getElementsByTagName('*');
for (var i = 0; i<elems.length; i++) {
var elem = elems[i];
var style = window.getComputedStyle(elem, null);
var value = style.getPropertyValue("background-image");
if (value && value != "" && value != "none")
outputArray.push(value);
}
However, I want this to work on any file out there (running as a bookmarklet), and I know url() can apply to things that aren't background images, for instance "list-style-image". Are there more? Is there a list of these somewhere?