Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(function () {
'use strict';
var i, image, j, matches, rules, sheet;
for (i = 0; i < document.styleSheets.length; ++i) {
sheet = document.styleSheets[i];
if (sheet.rules) {
for (j = 0; j < sheet.rules.length; ++j) {
rules = sheet.rules[j];
if (rules.style && rules.style.backgroundImage) {
matches = rules.style.backgroundImage.match(/url\((.*)\)/);
if (matches) {
image = new Image;
image.src = matches[1];
}
}
}
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment