Last active
November 8, 2016 01:00
-
-
Save kobake/e82b1f41cacdb7d66cc78ce1c3c5d5c0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
window.$ = $; | |
$(function(){ | |
var LIMIT = 24; // この分数経ったら止める | |
setInterval(function(){ | |
// 再生開始の監視 | |
if(!$('.control-play-pause').find('i').hasClass('mdi-av-play-arrow')){ // 再生中 | |
if(!parseInt(localStorage.getItem('starttime'))){ | |
console.log("START!"); | |
localStorage.setItem('starttime', new Date().getTime()); | |
} | |
} | |
else{ | |
localStorage.setItem('starttime', 0); | |
} | |
// 停止時間の監視 | |
if(!$('.control-play-pause').find('i').hasClass('mdi-av-play-arrow')){ // 再生中 | |
var elapsedMinutes = (new Date().getTime() - parseInt(localStorage.getItem('starttime'))) / 1000 / 60; | |
console.log("elapsedMinutes = " + elapsedMinutes); | |
if(elapsedMinutes >= LIMIT){ | |
localStorage.setItem('starttime', 0); | |
$('.control-play-pause').click(); | |
} | |
} | |
}, 1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment