最近喜欢用百度音乐盒听音乐,但是有一个让人蛋疼的问题:每当当前歌曲播放结束下一首播放之前偶尔会插播一段语音广告...
直接看脚本吧
1 function fRandomBy(under, over){ 2 switch(arguments.length){ 3 case 1: return parseInt(Math.random()*under+1); 4 case 2: return parseInt(Math.random()*(over-under+1) + under); 5 default: return 0; 6 } 7 } 8 $(function(){ 9 setInterval(function(){ 10 if($(\'.curTime\').text().replace("00:00","")==$(\'.totalTime\').text().substr(0,$(\'.totalTime\').text().length-1)+"0"){ 11 var curSong=fRandomBy(1,$(\'.playlist-length\').text().replace(/\D/g,\'\')); 12 console.log(curSong); 13 $(\'div[reellist-row=\'+curSong+\']\').dblclick() 14 } 15 },1000) 16 })
具体做法:在当前歌曲播放结束之前随机播放列表中的一首歌曲。
function:取区间随机数
setInterval函数之所以写在$(function(){})里面是因为播放下一首歌曲的时候页面ReLoad了。
<OVER>