Skip to content

Instantly share code, notes, and snippets.

@kobake
Last active November 8, 2016 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kobake/e82b1f41cacdb7d66cc78ce1c3c5d5c0 to your computer and use it in GitHub Desktop.
Save kobake/e82b1f41cacdb7d66cc78ce1c3c5d5c0 to your computer and use it in GitHub Desktop.
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