Last active
April 27, 2019 06:51
-
-
Save nobodyzxc/b7993fd6e6f659b182f2642774334662 to your computer and use it in GitHub Desktop.
for Drrr
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
// press F12 and click the console, paste the code below to the console, then enter. | |
var ordering = false; | |
var order_song = function (name) { | |
return function(link){ | |
ordering = true; | |
console.log('lnk is:') | |
console.log(link); | |
$('#form-room-music-url').val(link); | |
$('#form-room-music-name').val(name); | |
document.getElementsByName('play')[0].click(); | |
} | |
} | |
var progress = ''; | |
/* use funcs below to impl a music auto player */ | |
var monitMusic = function(callback_next){ | |
return function(){ | |
try{ | |
var cur = $("#musicBox > div > div.progress-music.active")[0].style.width; | |
if(progress === cur){ | |
if(!ordering){ | |
console.log('next'); | |
callback_next(); | |
} | |
} | |
else{ | |
if(ordering) ordering = false; | |
cur = progress; | |
console.log('moniting'); | |
} | |
} | |
catch(err){ | |
if(!ordering){ | |
console.log('cannot get progress, begin.'); | |
callback_next(); | |
} | |
} | |
} | |
} | |
function Repeater(title, url){ | |
this.title = title; | |
this.url = url; | |
this.interval = undefined; | |
this.start = function(){ | |
this.interval = setInterval( | |
monitMusic(() => order_song(this.title)(this.url)), | |
2000 | |
); | |
} | |
this.stop = function(){ | |
clearInterval(this.interval); | |
} | |
} | |
var repeater = new Repeater('', "http://music.163.com/#/song?id=1349303599"); | |
repeater.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment