citp / news-disinformation-study

A research project on how web users consume, are exposed to, and share news online.
8 stars 2 forks source link

Measure link visibility in LinkExposure studies #22

Closed jonathanmayer closed 4 years ago

jonathanmayer commented 4 years ago

Note that the linkExposure content script can only determine whether the page is in the active tab in its window. It cannot determine whether the browser is active or its window has focus. We'll have to pass that information to the content script (e.g., by listening to attention events from the PageEvent module and forwarding them to the relevant tabs).

A couple of design directions:

  1. Periodically iterate over elements and check for visibility (e.g., comparing to the viewport with getBoundingClientRect). This is probably the place to start.
  2. Use an IntersectionObserver on each element to listen for visibility changes.
jonathanmayer commented 4 years ago

Also, just a reminder to please not use jQuery (91371a53615bb26439c1f1eb251d4ba48d7a557b) in the content script environment. That's a lot of unnecessary bulk to add to every page load.