Skip to content

Instantly share code, notes, and snippets.

@makaroni4
Created September 27, 2015 21:12
Show Gist options
  • Save makaroni4/ed325533815a70144a87 to your computer and use it in GitHub Desktop.
Save makaroni4/ed325533815a70144a87 to your computer and use it in GitHub Desktop.
Grace Monkey script to show the remain lessons count
$(function(){
function drawLessonsCount(count) {
$(".topbar-nav-main").append("<li style='display: block; color: #fff; padding: 8px 15px;'>Осталось уроков: " + count + "</li>");
}
function countLessons() {
var count = 0;
$(".lessons-left").each(function(index, element) {
var text = $(element).text();
if(text) {
count += Number(text.split("/")[1]);
}
})
return count;
}
function timerHandler() {
console.log(".JS >>> Trying to find number of lessons");
if($(".skill-tree").length) {
var numberOfLessons = countLessons();
drawLessonsCount(numberOfLessons);
stopTimer();
}
}
function stopTimer() {
clearInterval(timer);
}
var timer = setInterval(function(){ timerHandler() }, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment