From cd810f89d309691ee909bd7713cc7d6dbbe058c6 Mon Sep 17 00:00:00 2001 From: thc202 Date: Fri, 18 Jul 2025 08:34:20 +0100 Subject: [PATCH] Report elements with pointer style Report all elements that have cursor pointer style as that strongly implies that the elements can be interacted with. Signed-off-by: thc202 --- CHANGELOG.md | 5 +++++ CHANGELOG.rec.md | 2 ++ source/ContentScript/index.ts | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3876e7c..c4d54a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to the full browser extension will be documented in this fil The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## Unreleased + +### Added +- Report elements that have cursor pointer style. + ## 0.1.4 - 2025-06-30 ### Fixed diff --git a/CHANGELOG.rec.md b/CHANGELOG.rec.md index 1c21e89..8801a96 100644 --- a/CHANGELOG.rec.md +++ b/CHANGELOG.rec.md @@ -3,6 +3,8 @@ All notable changes to the recorder browser extension will be documented in this The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## Unreleased + ## 0.1.4 - 2025-06-30 ### Added diff --git a/source/ContentScript/index.ts b/source/ContentScript/index.ts index d8546c4..da67447 100644 --- a/source/ContentScript/index.ts +++ b/source/ContentScript/index.ts @@ -184,6 +184,22 @@ function reportNodeElements( } } +function reportPointerElements( + source: Element | Document, + fn: (re: ReportedObject) => void +): void { + source.querySelectorAll('*').forEach((element) => { + const {tagName} = element; + const url = window.location.href; + if (tagName !== 'input' && tagName !== 'button' && tagName !== 'a') { + const compStyles = window.getComputedStyle(element, 'hover'); + if (compStyles.getPropertyValue('cursor') === 'pointer') { + fn(new ReportedElement(element, url)); + } + } + }); +} + function reportPageLoaded( doc: Document, fn: (re: ReportedObject) => void @@ -197,6 +213,7 @@ function reportPageLoaded( reportPageForms(doc, fn); reportElements(doc.getElementsByTagName('input'), fn); reportElements(doc.getElementsByTagName('button'), fn); + reportPointerElements(doc, fn); reportStorage(LOCAL_STORAGE, localStorage, fn); reportStorage(SESSION_STORAGE, sessionStorage, fn); } @@ -209,10 +226,14 @@ const domMutated = function domMutation( reportEvent(new ReportedEvent('domMutation')); reportPageLinks(document, reportObject); reportPageForms(document, reportObject); + reportPointerElements(document, reportObject); for (const mutation of mutationList) { if (mutation.type === 'childList') { reportNodeElements(mutation.target, 'input', reportObject); reportNodeElements(mutation.target, 'button', reportObject); + if (mutation.target.nodeType === Node.ELEMENT_NODE) { + reportPointerElements(mutation.target as Element, reportObject); + } } } });