This commit is contained in:
gorhill 2015-05-01 19:11:36 -04:00
parent 31a36a63d9
commit 09354ce7e2
1 changed files with 20 additions and 2 deletions

View File

@ -246,9 +246,27 @@ var uBlockCollapser = (function() {
newRequests.push(new BouncingRequest(req.id, tagName, src)); newRequests.push(new BouncingRequest(req.id, tagName, src));
}; };
var addIFrame = function(iframe) { var iframeSourceModified = function(mutations) {
var i = mutations.length;
while ( i-- ) {
addIFrame(mutations[i].target, true);
}
process();
};
var iframeSourceObserver = new MutationObserver(iframeSourceModified);
var iframeSourceObserverOptions = {
attributes: true,
attributeFilter: [ 'src' ]
};
var addIFrame = function(iframe, dontObserve) {
// https://github.com/gorhill/uBlock/issues/162
// Be prepared to deal with possible change of src attribute.
if ( dontObserve !== true ) {
iframeSourceObserver.observe(iframe, iframeSourceObserverOptions);
}
var src = iframe.src; var src = iframe.src;
// TODO: niject content script in `about:blank` as well.
if ( src === '' || typeof src !== 'string' ) { if ( src === '' || typeof src !== 'string' ) {
return; return;
} }