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