How to record how much time user has spent on my node? I want to record the time a user has spent on my particular node so I could show a pop up to the user to register once the user has read 3 article. But the user must have spent at least 30 seconds on each node. 

There is the Time Spent module available, but I wonder if I can merge it with another (custom) module I have created (which records the number of nodes user have visited)?
Without using any custom modules

Drupal core doesn't have any such feature. So if you don't want to consider using a contributed module, the only options you have is to:


Write a custom module (or further enhance the custom module you already have for it).
Add something like a javascript to the theme(s) you're using.
Wait for a future release of Drupal (core) that may include such feature.
Consider using a contributed module (e.g. as further explained below).


Using the Javascript Timer module

The Javascript Timer module (available for D6 and D7) seems to be a possible answer to your question. Here is a quote from its project page:


  ... provides a timer API that can hook HTML elements to javascript widget objects. This is useful if you want a moving timer/clock or a widget that updates every second. It comes with widgets for a count-down timer, a count-up timer, and a clock. It uses jQuery and a single event loop to handle as many timers as you need on a single page.


Its Readme.txt file contains various examples, both Inline HTML Examples and PHP Input Format Examples.

Comment #4 in issue #1195560 contains an interesting comment that may help to get you going:


  It allows for redirecting to a new URL or refreshing the existing page.
  On the setting page it is called "Timer complete redirect". If you use a "redirect path" of &lt;reload&gt; it will just reload the current page.