YouTube™ Time Tracker is a Chrome Extension that tracks time you spent on YouTube. It's important to notice that it uses only local chrome.storage API to store data and it does't send data anywhere
Although local chrome.storage allows us to store up to 5 Mb of data extension keeps its data very simple, just JSON with 8 keys for current/previous time periods:
{
"2019": 110.2, // year
"jan-2019": 110.2, // month
"2-2019": 110.2, // week (0-52)
"2019-01-13": 110.2, // today
"2018": 10294, // previous year
"dec-2018": 1248, // previous month
"1-2019": 159, // previous week
"2019-01-12": 91 // yesterday,
"time_watched": 10404.2 // total time watched,
"installed_at": "2019-01-01" // when extension was installed
}
Use npm install
to install needed packages (there are just a bunch: webpack, babel, jest and timekeeer for testing).
Then run npm start
for Webpack to watch and compile JS files.
Load extension folder to chrome://extensions/ via "Load unpacked":
extension
folder.
To run tests use npm test
.
Tests are written with jest with a bunch of custom matchers and custom helper functions.