1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00
This commit is contained in:
gorhill 2015-05-01 19:06:52 -04:00
parent ca1e1f55e7
commit 5023c563a7

View File

@ -227,9 +227,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;
}