1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-06 02:42:33 +01:00
This commit is contained in:
gorhill 2015-05-01 19:11:36 -04:00
parent 31a36a63d9
commit 09354ce7e2

View File

@ -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;
}