mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-11 09:31:01 +01:00
fix #2552
This commit is contained in:
parent
5f72565f7a
commit
797082a36c
1 changed files with 23 additions and 21 deletions
|
@ -890,7 +890,7 @@ return domFilterer;
|
||||||
vAPI.domWatcher = (function() {
|
vAPI.domWatcher = (function() {
|
||||||
|
|
||||||
var domLayoutObserver = null,
|
var domLayoutObserver = null,
|
||||||
ignoreTags = { 'head': 1, 'link': 1, 'meta': 1, 'script': 1, 'style': 1 },
|
ignoreTags = new Set([ 'head', 'link', 'meta', 'script', 'style' ]),
|
||||||
addedNodeLists = [],
|
addedNodeLists = [],
|
||||||
addedNodes = [],
|
addedNodes = [],
|
||||||
removedNodes = false,
|
removedNodes = false,
|
||||||
|
@ -899,30 +899,30 @@ vAPI.domWatcher = (function() {
|
||||||
var safeObserverHandler = function() {
|
var safeObserverHandler = function() {
|
||||||
safeObserverHandlerTimer.clear();
|
safeObserverHandlerTimer.clear();
|
||||||
var i = addedNodeLists.length,
|
var i = addedNodeLists.length,
|
||||||
|
j = addedNodes.length,
|
||||||
nodeList, iNode, node;
|
nodeList, iNode, node;
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
nodeList = addedNodeLists[i];
|
nodeList = addedNodeLists[i];
|
||||||
iNode = nodeList.length;
|
iNode = nodeList.length;
|
||||||
while ( iNode-- ) {
|
while ( iNode-- ) {
|
||||||
node = nodeList[iNode];
|
node = nodeList[iNode];
|
||||||
if ( node.nodeType !== 1 ) {
|
if (
|
||||||
continue;
|
node.nodeType === 1 &&
|
||||||
|
ignoreTags.has(node.localName) === false &&
|
||||||
|
node.parentElement !== null
|
||||||
|
) {
|
||||||
|
addedNodes[j++] = node;
|
||||||
}
|
}
|
||||||
if ( ignoreTags[node.localName] === 1 ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
addedNodes.push(node);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addedNodeLists.length = 0;
|
addedNodeLists.length = 0;
|
||||||
if ( addedNodes.length !== 0 || removedNodes ) {
|
if ( j === 0 && removedNodes === false ) { return; }
|
||||||
listeners[0](addedNodes);
|
listeners[0](addedNodes);
|
||||||
if ( listeners[1] ) {
|
if ( listeners[1] ) {
|
||||||
listeners[1](addedNodes);
|
listeners[1](addedNodes);
|
||||||
}
|
}
|
||||||
addedNodes.length = 0;
|
addedNodes.length = 0;
|
||||||
removedNodes = false;
|
removedNodes = false;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var safeObserverHandlerTimer = new vAPI.SafeAnimationFrame(safeObserverHandler);
|
var safeObserverHandlerTimer = new vAPI.SafeAnimationFrame(safeObserverHandler);
|
||||||
|
@ -1024,6 +1024,7 @@ vAPI.domCollapser = (function() {
|
||||||
};
|
};
|
||||||
var netSelectorCacheCount = 0,
|
var netSelectorCacheCount = 0,
|
||||||
messaging = vAPI.messaging;
|
messaging = vAPI.messaging;
|
||||||
|
|
||||||
var cachedBlockedSetClear = function() {
|
var cachedBlockedSetClear = function() {
|
||||||
cachedBlockedSet =
|
cachedBlockedSet =
|
||||||
cachedBlockedSetHash =
|
cachedBlockedSetHash =
|
||||||
|
@ -1033,8 +1034,7 @@ vAPI.domCollapser = (function() {
|
||||||
// https://github.com/chrisaljoudi/uBlock/issues/174
|
// https://github.com/chrisaljoudi/uBlock/issues/174
|
||||||
// Do not remove fragment from src URL
|
// Do not remove fragment from src URL
|
||||||
var onProcessed = function(response) {
|
var onProcessed = function(response) {
|
||||||
// This can happens if uBO is restarted.
|
if ( !response ) { // This can happens if uBO is restarted.
|
||||||
if ( !response ) {
|
|
||||||
toCollapse.clear();
|
toCollapse.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1048,9 +1048,11 @@ vAPI.domCollapser = (function() {
|
||||||
if ( cachedBlockedSetTimer !== undefined ) {
|
if ( cachedBlockedSetTimer !== undefined ) {
|
||||||
clearTimeout(cachedBlockedSetTimer);
|
clearTimeout(cachedBlockedSetTimer);
|
||||||
}
|
}
|
||||||
if ( cachedBlockedSet.size === 0 ) { return; }
|
|
||||||
cachedBlockedSetTimer = vAPI.setTimeout(cachedBlockedSetClear, 30000);
|
cachedBlockedSetTimer = vAPI.setTimeout(cachedBlockedSetClear, 30000);
|
||||||
}
|
}
|
||||||
|
if ( cachedBlockedSet === undefined || cachedBlockedSet.size === 0 ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var selectors = [],
|
var selectors = [],
|
||||||
iframeLoadEventPatch = vAPI.iframeLoadEventPatch,
|
iframeLoadEventPatch = vAPI.iframeLoadEventPatch,
|
||||||
netSelectorCacheCountMax = response.netSelectorCacheCountMax,
|
netSelectorCacheCountMax = response.netSelectorCacheCountMax,
|
||||||
|
@ -1545,7 +1547,7 @@ vAPI.domSurveyor = (function() {
|
||||||
v = node.id;
|
v = node.id;
|
||||||
if ( typeof v !== 'string' ) { continue; }
|
if ( typeof v !== 'string' ) { continue; }
|
||||||
v = '#' + v.trim();
|
v = '#' + v.trim();
|
||||||
if ( !qq.has(v) && v.length !== 1 ) {
|
if ( qq.has(v) === false && v.length !== 1 ) {
|
||||||
ll[lli] = v; lli++; qq.add(v);
|
ll[lli] = v; lli++; qq.add(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1555,9 +1557,9 @@ vAPI.domSurveyor = (function() {
|
||||||
node = nodes[i];
|
node = nodes[i];
|
||||||
vv = node.className;
|
vv = node.className;
|
||||||
if ( typeof vv !== 'string' ) { continue; }
|
if ( typeof vv !== 'string' ) { continue; }
|
||||||
if ( !rews.test(vv) ) {
|
if ( rews.test(vv) === false ) {
|
||||||
v = '.' + vv;
|
v = '.' + vv;
|
||||||
if ( !qq.has(v) && v.length !== 1 ) {
|
if ( qq.has(v) === false && v.length !== 1 ) {
|
||||||
ll[lli] = v; lli++; qq.add(v);
|
ll[lli] = v; lli++; qq.add(v);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1565,7 +1567,7 @@ vAPI.domSurveyor = (function() {
|
||||||
j = vv.length;
|
j = vv.length;
|
||||||
while ( j-- ) {
|
while ( j-- ) {
|
||||||
v = '.' + vv[j];
|
v = '.' + vv[j];
|
||||||
if ( !qq.has(v) ) {
|
if ( qq.has(v) === false ) {
|
||||||
ll[lli] = v; lli++; qq.add(v);
|
ll[lli] = v; lli++; qq.add(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue