mirror of https://github.com/gorhill/uBlock.git
Better lookup all elements under mouse cursor in element picker
Related feedback: - https://www.reddit.com/r/uBlockOrigin/comments/pefaov/elementpickerzapper_often_misses_images/hcnycbx/?context=3
This commit is contained in:
parent
1219d57561
commit
d930504e3e
|
@ -524,11 +524,6 @@ const filtersFrom = function(x, y) {
|
||||||
x = undefined;
|
x = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network filter from element which was clicked.
|
|
||||||
if ( first !== null ) {
|
|
||||||
netFilterFromElement(first);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cosmetic filter candidates from ancestors.
|
// Cosmetic filter candidates from ancestors.
|
||||||
// https://github.com/gorhill/uBlock/issues/2519
|
// https://github.com/gorhill/uBlock/issues/2519
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/17
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/17
|
||||||
|
@ -549,23 +544,15 @@ const filtersFrom = function(x, y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/1545
|
// https://github.com/gorhill/uBlock/issues/1545
|
||||||
// Network filter candidates from all other elements found at
|
// Network filter candidates from all other elements found at [x,y].
|
||||||
// point (x, y).
|
|
||||||
if ( typeof x === 'number' ) {
|
if ( typeof x === 'number' ) {
|
||||||
const attrName = vAPI.sessionId + '-clickblind';
|
const magicAttr = `${vAPI.sessionId}-clickblind`;
|
||||||
elem = first;
|
pickerRoot.setAttribute(magicAttr, '');
|
||||||
while ( elem !== null ) {
|
const elems = document.elementsFromPoint(x, y);
|
||||||
const previous = elem;
|
pickerRoot.removeAttribute(magicAttr);
|
||||||
elem.setAttribute(attrName, '');
|
for ( const elem of elems ) {
|
||||||
elem = elementFromPoint(x, y);
|
|
||||||
if ( elem === null || elem === previous ) { break; }
|
|
||||||
netFilterFromElement(elem);
|
netFilterFromElement(elem);
|
||||||
}
|
}
|
||||||
for ( const elem of document.querySelectorAll(`[${attrName}]`) ) {
|
|
||||||
elem.removeAttribute(attrName);
|
|
||||||
}
|
|
||||||
|
|
||||||
netFilterFromElement(document.body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return netFilterCandidates.length + cosmeticFilterCandidates.length;
|
return netFilterCandidates.length + cosmeticFilterCandidates.length;
|
||||||
|
|
Loading…
Reference in New Issue