Skip to content

Instantly share code, notes, and snippets.

@cvializ
Created May 12, 2016 00:13
Show Gist options
  • Save cvializ/cb5e9a8158877c8b34ae4733ad587b81 to your computer and use it in GitHub Desktop.
Save cvializ/cb5e9a8158877c8b34ae4733ad587b81 to your computer and use it in GitHub Desktop.
Check the DOM for images that need to be loaded from the background page
function onCspCheckLoaded(isCspBlocking) {
extension_module.csp = isCspBlocking; // cache the check value
if (isCspBlocking) {
// Capture error events triggered by img tags
document.addEventListener('error', onExtensionImgError, true);
// Check for background images
var observer = new MutationObserver(withMutations);
var whatToObserve = { childList: true, subtree: true };
observer.observe(document, whatToObserve);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment