Skip to content

Commit c0f780f

Browse files
committed
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 <thc202@gmail.com>
1 parent c539b04 commit c0f780f

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ All notable changes to the full browser extension will be documented in this fil
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6+
## Unreleased
7+
8+
### Added
9+
- Report elements that have cursor pointer style.
10+
611
## 0.1.8 - 2025-12-12
712

813
### Changed

CHANGELOG.rec.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ All notable changes to the recorder browser extension will be documented in this
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6+
## Unreleased
7+
68
## 0.1.8 - 2025-12-12
79

810
### Changed

source/ContentScript/index.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,27 @@ function reportNodeElements(
184184
}
185185
}
186186

187+
function reportPointerElements(
188+
source: Element | Document,
189+
fn: (re: ReportedObject) => void
190+
): void {
191+
source.querySelectorAll('*').forEach((element) => {
192+
const {tagName} = element;
193+
const url = window.location.href;
194+
if (
195+
tagName !== 'input' &&
196+
tagName !== 'button' &&
197+
tagName !== 'a' &&
198+
element instanceof Element
199+
) {
200+
const compStyles = window.getComputedStyle(element, 'hover');
201+
if (compStyles.getPropertyValue('cursor') === 'pointer') {
202+
fn(new ReportedElement(element, url));
203+
}
204+
}
205+
});
206+
}
207+
187208
function reportPageLoaded(
188209
doc: Document,
189210
fn: (re: ReportedObject) => void
@@ -197,6 +218,7 @@ function reportPageLoaded(
197218
reportPageForms(doc, fn);
198219
reportElements(doc.getElementsByTagName('input'), fn);
199220
reportElements(doc.getElementsByTagName('button'), fn);
221+
reportPointerElements(doc, fn);
200222
reportStorage(LOCAL_STORAGE, localStorage, fn);
201223
reportStorage(SESSION_STORAGE, sessionStorage, fn);
202224
}
@@ -209,10 +231,14 @@ const domMutated = function domMutation(
209231
reportEvent(new ReportedEvent('domMutation'));
210232
reportPageLinks(document, reportObject);
211233
reportPageForms(document, reportObject);
234+
reportPointerElements(document, reportObject);
212235
for (const mutation of mutationList) {
213236
if (mutation.type === 'childList') {
214237
reportNodeElements(mutation.target, 'input', reportObject);
215238
reportNodeElements(mutation.target, 'button', reportObject);
239+
if (mutation.target.nodeType === Node.ELEMENT_NODE) {
240+
reportPointerElements(mutation.target as Element, reportObject);
241+
}
216242
}
217243
}
218244
});

0 commit comments

Comments
 (0)