Recently like to use the Baidu Music box to listen to music, but there is a human egg pain problem: Every time the current song playback end of the next song will occasionally be interrupted a voice ad ...
Just look at the script.
1 functionFrandomby (under, over) {2 Switch(arguments.length) {3 Case1:returnparseint (Math.random () *under+1);4 Case2:returnparseint (Math.random () * (over-under+1) +under);5 default:return0;6 }7 } 8$(function(){9SetInterval (function(){Ten if($ ('. Curtime '). Text (). replace ("00:00", "") ==$ ('. TotalTime '). Text (). substr (0,$ ('. TotalTime '). Text (). length-1) + "0 "){ One varCursong=frandomby (1,$ ('. Playlist-length '). Text (). Replace (/\d/g, ")); A Console.log (cursong); -$ (' div[reellist-row= ' +cursong+ ') '). DblClick () - } the},1000) -})
View Code
Practice: A song in a random playlist before the end of the current song play.
function: Take interval random number
The SetInterval function is written in $ (function () {}) because the page reload when the next song is played.
<OVER>
About Baidu Music Box