Skip to content

Instantly share code, notes, and snippets.

@brikis98 brikis98/script.js
Last active Mar 7, 2018

Embed
What would you like to do?
Get course summary from Teachable
var result = $('.section-item .item').get().reduce(function(total, item) {
var text = $(item).text().split("\n").join(" ");
var matches = /.+\((\d):(\d\d)\)/g.exec(text);
var minutes = parseInt(matches[1]);
var seconds = parseInt(matches[2]);
var totalMin = total[0] + minutes;
var totalSec = total[1] + seconds;
if (totalSec > 60) {
totalMin += 1;
totalSec -= 60;
}
return [totalMin, totalSec]
}, [0,0]);
console.log($('.section-item .item').size() + " micro videos, " + result[0] + " minutes, " + result[1] + " seconds");
@brikis98

This comment has been minimized.

Copy link
Owner Author

commented Mar 7, 2018

I needed a way to quickly count the number of videos and the total course duration for courses on Teachable. There's no obvious way to find this info in the UI, so I wrote a very hacky JS script to calculate it.

Instructions:

  1. Go to the page for the course (e.g., https://training.gruntwork.io/p/terraform)
  2. Open the web dev console
  3. Paste the script above and hit enter
  4. You should get output like: "30 micro videos, 92 minutes, 53 seconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.