From 09354ce7e2ea471f9633a9d722f2b2a860ad3db9 Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 1 May 2015 19:11:36 -0400 Subject: [PATCH] this fixes https://github.com/gorhill/uBlock/issues/162 --- src/js/contentscript-end.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index db1af9cb8..127d76bd1 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -246,9 +246,27 @@ var uBlockCollapser = (function() { 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; - // TODO: niject content script in `about:blank` as well. if ( src === '' || typeof src !== 'string' ) { return; }