This demo accurately measures how long you've spent actively viewing this page using the VisibilityStateEntry API.
VisibilityStateEntry