mirror of https://github.com/gorhill/uBlock.git
fix #2609
This commit is contained in:
parent
a97c5cdaf4
commit
8f42232105
|
@ -233,7 +233,7 @@ var platformHideNode = vAPI.hideNode,
|
||||||
var uid,
|
var uid,
|
||||||
timer,
|
timer,
|
||||||
observer,
|
observer,
|
||||||
changedNodes = [],
|
changedNodes = new Set(),
|
||||||
observerOptions = {
|
observerOptions = {
|
||||||
attributes: true,
|
attributes: true,
|
||||||
attributeFilter: [ 'style' ]
|
attributeFilter: [ 'style' ]
|
||||||
|
@ -256,34 +256,33 @@ var platformHideNode = vAPI.hideNode,
|
||||||
// on sites which try to use inline styles to bypass blockers.
|
// on sites which try to use inline styles to bypass blockers.
|
||||||
var batchProcess = function() {
|
var batchProcess = function() {
|
||||||
timer.clear();
|
timer.clear();
|
||||||
var cNodes = changedNodes, i = cNodes.length,
|
var uid_ = uid;
|
||||||
vNodes = [], j = 0,
|
for ( var node of changedNodes ) {
|
||||||
node;
|
if (
|
||||||
while ( i-- ) {
|
node[uid_] === undefined ||
|
||||||
node = cNodes[i];
|
node.clientHeight === 0 || node.clientWidth === 0
|
||||||
if ( node[uid] !== undefined && node.clientHeight && node.clientWidth ) {
|
) {
|
||||||
vNodes[j++] = node;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
cNodes.length = 0;
|
|
||||||
while ( j-- ) {
|
|
||||||
node = vNodes[j];
|
|
||||||
var attr = node.getAttribute('style');
|
var attr = node.getAttribute('style');
|
||||||
if ( !attr ) {
|
if ( attr === null ) {
|
||||||
attr = '';
|
attr = '';
|
||||||
} else {
|
} else if (
|
||||||
|
attr.length !== 0 &&
|
||||||
|
attr.charCodeAt(attr.length - 1) !== 0x3B /* ';' */
|
||||||
|
) {
|
||||||
attr += '; ';
|
attr += '; ';
|
||||||
}
|
}
|
||||||
node.setAttribute('style', attr + 'display: none !important;');
|
node.setAttribute('style', attr + 'display: none !important;');
|
||||||
}
|
}
|
||||||
|
changedNodes.clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
var observerHandler = function(mutations) {
|
var observerHandler = function(mutations) {
|
||||||
var i = mutations.length,
|
var i = mutations.length,
|
||||||
cNodes = changedNodes,
|
changedNodes_ = changedNodes;
|
||||||
j = cNodes.length;
|
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
cNodes[j++] = mutations[i].target;
|
changedNodes_.add(mutations[i].target);
|
||||||
}
|
}
|
||||||
timer.start();
|
timer.start();
|
||||||
};
|
};
|
||||||
|
@ -297,8 +296,7 @@ var platformHideNode = vAPI.hideNode,
|
||||||
node[uid] = node.hasAttribute('style') && (node.getAttribute('style') || '');
|
node[uid] = node.hasAttribute('style') && (node.getAttribute('style') || '');
|
||||||
}
|
}
|
||||||
// Performance: batch-process nodes to hide.
|
// Performance: batch-process nodes to hide.
|
||||||
var cNodes = changedNodes;
|
changedNodes.add(node);
|
||||||
cNodes[cNodes.length] = node;
|
|
||||||
timer.start();
|
timer.start();
|
||||||
if ( observer === undefined ) {
|
if ( observer === undefined ) {
|
||||||
observer = new MutationObserver(observerHandler);
|
observer = new MutationObserver(observerHandler);
|
||||||
|
|
Loading…
Reference in New Issue