Created
September 27, 2015 21:12
-
-
Save makaroni4/ed325533815a70144a87 to your computer and use it in GitHub Desktop.
Grace Monkey script to show the remain lessons count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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