Javascript code that calculates how much active time is spent on a tab and takes into account changing tabs, switching windows, or leaving the page.
Demo here http://bl.ocks.org/d/4393523/
| // npm i request cheerio json2csv | |
| var fs = require('fs'), | |
| request = require('request'), | |
| cheerio = require('cheerio'), | |
| json2csv = require('json2csv'); | |
| var HOST = 'https://www.ptt.cc'; | |
| var getMenu = function (url, callback, links) { | |
| var links = links || []; // Set default value for links (initial call) |
| /* | |
| Copyright 2011 Martin Hawksey | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software |
Javascript code that calculates how much active time is spent on a tab and takes into account changing tabs, switching windows, or leaving the page.
Demo here http://bl.ocks.org/d/4393523/