From 4a01affa0e4a728b0196432fdddd16ddff709345 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 13 Nov 2022 11:07:41 -0500 Subject: [PATCH] Undo mistakenly committed changes to the element picker Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2360 --- src/js/scriptlets/epicker.js | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/js/scriptlets/epicker.js b/src/js/scriptlets/epicker.js index 6fed5ac64..875839b81 100644 --- a/src/js/scriptlets/epicker.js +++ b/src/js/scriptlets/epicker.js @@ -113,16 +113,6 @@ const getElementBoundingClientRect = function(elem) { /******************************************************************************/ -const elementsFromPoint = function(parent, x, y) { - const elems = parent.elementsFromPoint(x, y); - if ( elems.length !== 0 && elems[0].shadowRoot !== null ) { - return elementsFromPoint(elems[0].shadowRoot, x, y); - } - return elems; -}; - -/******************************************************************************/ - const highlightElements = function(elems, force) { // To make mouse move handler more efficient if ( @@ -564,11 +554,11 @@ const filtersFrom = function(x, y) { // Network filter candidates from all other elements found at [x,y]. // https://www.reddit.com/r/uBlockOrigin/comments/qmjk36/ // Extract network candidates first. - const magicAttr = `${vAPI.sessionId}-clickblind`; - pickerRoot.setAttribute(magicAttr, ''); - const elems = elementsFromPoint(document, x, y); - pickerRoot.removeAttribute(magicAttr); 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); } @@ -580,14 +570,11 @@ const filtersFrom = function(x, y) { // https://github.com/gorhill/uBlock/issues/2519 // https://github.com/uBlockOrigin/uBlock-issues/issues/17 // Prepend `body` if full selector is ambiguous. - for ( const elem of elems ) { + let elem = first; + while ( elem && elem !== document.body ) { cosmeticFilterFromElement(elem); + elem = elem.parentNode; } - //let elem = first; - //while ( elem && elem !== document.body ) { - // cosmeticFilterFromElement(elem); - // elem = elem.parentNode; - //} // The body tag is needed as anchor only when the immediate child // uses `nth-of-type`. let i = cosmeticFilterCandidates.length;