From 3647fb822bd41403bccf9837c63f916d34b24398 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 13 Nov 2023 18:09:53 +0100 Subject: [PATCH] Attempt to handle #text --- changedetectionio/res/xpath_element_scraper.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/changedetectionio/res/xpath_element_scraper.js b/changedetectionio/res/xpath_element_scraper.js index aac27f49..efe593d0 100644 --- a/changedetectionio/res/xpath_element_scraper.js +++ b/changedetectionio/res/xpath_element_scraper.js @@ -185,6 +185,16 @@ if (include_filters.length) { } if (q) { + // Try to resolve //something/text() back to its /something so we can atleast get the bounding box + try { + if (typeof q.nodeName == 'string' && q.nodeName === '#text') { + q = q.parentElement + } + } catch (e) { + console.log(e) + console.log("xpath_element_scraper: #text resolver") + } + // #1231 - IN the case XPath attribute filter is applied, we will have to traverse up and find the element. if (typeof q.getBoundingClientRect == 'function') { bbox = q.getBoundingClientRect();