Search code examples
javascriptjquery

Plug.dj auto-grab


Anyone know of a way to auto-grab songs?

I want to make a playlist of songs so that I can make a playlist and listen to them. I've tried making a script but it somewhat worked, it opens the menu but it doesn't add it to the playlist. Here is my code:

function grab_song(){
    $(".icon-grab").click();
    $(".pop-menu ul li:first-child").click();
}
setTimeout("grab_song()", 5000);

The code is simple, and it will grab the song. But it will open the menu, and not grab the song. I used inspect element to try and disect the code to select the code to add it to the playlist, but so far, it just opens the menu.

Here is a screenshot of what I'm dealing with here:

https://i.sstatic.net/SMkqU.jpg

I'm sorry if this is a newb question, I'm learning jQuery still.

If anyone can help please do. Thanks!


Solution

  • context: this question is apparently specifically about the (now dysfunctional) service plug.dj

    Plug.js is actually listening for mousedown events on the pop-menu, not click events. You would have to replace the second .click() with a .mousedown(). Also you should use $("#grab") instead of $(".icon-grab"), as it's more reliable.

    A sample autograb script could look something like this:

    API.on("advance", window.autograb = function(){
      $("#grab").click()
      $(".pop-menu ul li:first-child").mousedown()
    })
    

    which could be stopped again with API.off("advance", window.autograb)