Skip to content

Commit

Permalink
Suggest network filter as best candidate by default
Browse files Browse the repository at this point in the history
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/qmjk36/

Regression from:
- gorhill@d930504

Also, fix immediately selecting the resource when using
contextual menu with cosmetic filtering off.
  • Loading branch information
gorhill committed Nov 4, 2021
1 parent 34738e5 commit 955fe94
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/js/scriptlets/epicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
};

Expand Down

0 comments on commit 955fe94

Please sign in to comment.