|
|
@ -166,21 +166,20 @@ var collapser = (function() {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var placeholders = response.placeholders,
|
|
|
|
let placeholders = response.placeholders;
|
|
|
|
tag, prop, src, collapsed, docurl, replaced;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( var target of targets ) {
|
|
|
|
for ( let target of targets ) {
|
|
|
|
tag = target.localName;
|
|
|
|
let tag = target.localName;
|
|
|
|
prop = src1stProps[tag];
|
|
|
|
let prop = src1stProps[tag];
|
|
|
|
if ( prop === undefined ) { continue; }
|
|
|
|
if ( prop === undefined ) { continue; }
|
|
|
|
src = target[prop];
|
|
|
|
let src = target[prop];
|
|
|
|
if ( typeof src !== 'string' || src.length === 0 ) {
|
|
|
|
if ( typeof src !== 'string' || src.length === 0 ) {
|
|
|
|
prop = src2ndProps[tag];
|
|
|
|
prop = src2ndProps[tag];
|
|
|
|
if ( prop === undefined ) { continue; }
|
|
|
|
if ( prop === undefined ) { continue; }
|
|
|
|
src = target[prop];
|
|
|
|
src = target[prop];
|
|
|
|
if ( typeof src !== 'string' || src.length === 0 ) { continue; }
|
|
|
|
if ( typeof src !== 'string' || src.length === 0 ) { continue; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
collapsed = cachedBlockedMap.get(tagToTypeMap[tag] + ' ' + src);
|
|
|
|
let collapsed = cachedBlockedMap.get(tagToTypeMap[tag] + ' ' + src);
|
|
|
|
if ( collapsed === undefined ) { continue; }
|
|
|
|
if ( collapsed === undefined ) { continue; }
|
|
|
|
if ( collapsed ) {
|
|
|
|
if ( collapsed ) {
|
|
|
|
target.style.setProperty('display', 'none', 'important');
|
|
|
|
target.style.setProperty('display', 'none', 'important');
|
|
|
@ -190,7 +189,7 @@ var collapser = (function() {
|
|
|
|
switch ( tag ) {
|
|
|
|
switch ( tag ) {
|
|
|
|
case 'iframe':
|
|
|
|
case 'iframe':
|
|
|
|
if ( placeholders.frame !== true ) { break; }
|
|
|
|
if ( placeholders.frame !== true ) { break; }
|
|
|
|
docurl =
|
|
|
|
let docurl =
|
|
|
|
'data:text/html,' +
|
|
|
|
'data:text/html,' +
|
|
|
|
encodeURIComponent(
|
|
|
|
encodeURIComponent(
|
|
|
|
placeholders.frameDocument.replace(
|
|
|
|
placeholders.frameDocument.replace(
|
|
|
@ -198,7 +197,7 @@ var collapser = (function() {
|
|
|
|
src
|
|
|
|
src
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
replaced = false;
|
|
|
|
let replaced = false;
|
|
|
|
// Using contentWindow.location prevent tainting browser
|
|
|
|
// Using contentWindow.location prevent tainting browser
|
|
|
|
// history -- i.e. breaking back button (seen on Chromium).
|
|
|
|
// history -- i.e. breaking back button (seen on Chromium).
|
|
|
|
if ( target.contentWindow ) {
|
|
|
|
if ( target.contentWindow ) {
|
|
|
@ -214,6 +213,16 @@ var collapser = (function() {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'img':
|
|
|
|
case 'img':
|
|
|
|
if ( placeholders.image !== true ) { break; }
|
|
|
|
if ( placeholders.image !== true ) { break; }
|
|
|
|
|
|
|
|
// Do not insert placeholder if the image was actually loaded.
|
|
|
|
|
|
|
|
// This can happen if an allow rule was created while the
|
|
|
|
|
|
|
|
// document was loading.
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
target.complete &&
|
|
|
|
|
|
|
|
target.naturalWidth !== 0 &&
|
|
|
|
|
|
|
|
target.naturalHeight !== 0
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
target.style.setProperty('display', 'inline-block');
|
|
|
|
target.style.setProperty('display', 'inline-block');
|
|
|
|
target.style.setProperty('min-width', '20px', 'important');
|
|
|
|
target.style.setProperty('min-width', '20px', 'important');
|
|
|
|
target.style.setProperty('min-height', '20px', 'important');
|
|
|
|
target.style.setProperty('min-height', '20px', 'important');
|
|
|
|