Skip to content

makaroni4/youtube_time_tracker

Repository files navigation

YouTube™ Time Tracker Build Status Add to Chrome

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 ⚠️.

YouTube™ Time Tracker screenshots

Stored data format

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
}

Development

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":

Loading extension in Chrome for development.

⚠️ You'll need to update extension every time you changed CSS/JS files. ⚠️ Webpack will watch JS files and compile app.js file in extension folder.

Testing

To run tests use npm test.

Tests are written with jest with a bunch of custom matchers and custom helper functions.