1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00

Suggest network filter as best candidate by default

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/qmjk36/

Regression from:
- d930504e3e

Also, fix immediately selecting the resource when using
contextual menu with cosmetic filtering off.
This commit is contained in:
Raymond Hill 2021-11-04 12:42:48 -04:00
parent 34738e5291
commit 955fe944ca
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -524,6 +524,22 @@ const filtersFrom = function(x, y) {
x = undefined;
}
// https://github.com/gorhill/uBlock/issues/1545
// Network filter candidates from all other elements found at [x,y].
// https://www.reddit.com/r/uBlockOrigin/comments/qmjk36/
// Extract network candidates first.
if ( typeof x === 'number' ) {
const magicAttr = `${vAPI.sessionId}-clickblind`;
pickerRoot.setAttribute(magicAttr, '');
const elems = document.elementsFromPoint(x, y);
pickerRoot.removeAttribute(magicAttr);
for ( const elem of elems ) {
netFilterFromElement(elem);
}
} else if ( first !== null ) {
netFilterFromElement(first);
}
// Cosmetic filter candidates from ancestors.
// https://github.com/gorhill/uBlock/issues/2519
// https://github.com/uBlockOrigin/uBlock-issues/issues/17
@ -543,18 +559,6 @@ const filtersFrom = function(x, y) {
}
}
// https://github.com/gorhill/uBlock/issues/1545
// Network filter candidates from all other elements found at [x,y].
if ( typeof x === 'number' ) {
const magicAttr = `${vAPI.sessionId}-clickblind`;
pickerRoot.setAttribute(magicAttr, '');
const elems = document.elementsFromPoint(x, y);
pickerRoot.removeAttribute(magicAttr);
for ( const elem of elems ) {
netFilterFromElement(elem);
}
}
return netFilterCandidates.length + cosmeticFilterCandidates.length;
};