-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track site visits and time spent on sites #23
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
src/content_main.js
Outdated
* Get the current time based on the user's timezone. | ||
*/ | ||
function getCurrentTime() { | ||
return new Date(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: a more accurate alternative to new Date()
for the purposes of timing is performance.now()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note, new Date()
and performance.now()
have reduced time precision to protect against attacks.
new Date()
In Firefox, the privacy.reduceTimerPrecision preference is enabled by default and defaults to 20µs in Firefox 59; in 60 it will be 2ms.
performance.now()
In Firefox, the privacy.reduceTimerPrecision preference is enabled by default and defaults to 1ms.
https://developer.mozilla.org/en-US/docs/Web/API/Performance/now#Reduced_time_precision
Although performance.now()
has more precision than new Date()
, it might be less performant as a result - although its performance seems to be highly dependent on browser. As you can see below, the performance is pretty opposite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Informative! Nice.
track time spent on webpage add time spent on site every 2 seconds track number of visits to webpage store date of first visit to webpage store date of most recent visit to webpage Signed-off-by: sharon-wang <sharon-wang-cpsc@outlook.com>
095ded9
to
a062b7e
Compare
fixes: #3 , fixes: #7
NOTES
setInterval()
seems a bit sketchy