Advertisement
untoha

tampermonkey yandex music autoplay

Nov 3rd, 2017
1,474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name yandex music autoplay
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @run-at  document-end
  8. // @require http://code.jquery.com/jquery-1.12.4.min.js
  9. // @match  *://music.yandex.ru/users/tohadev/*
  10. // @grant none
  11. // ==/UserScript==
  12. console.log("START");
  13.  
  14. var iter = 0;
  15. function sleep(milliseconds) {
  16.     var start = new Date().getTime();
  17.     for (var i = 0; i < 1e7; i++) {
  18.         if ((new Date().getTime() - start) > milliseconds){
  19.             break;
  20.         }
  21.     }
  22. }
  23. function wtf()
  24. {
  25.     console.log("H WTF");
  26.  
  27.     console.log("iter:"+iter);
  28.     iter++;
  29.     if (iter == 5)
  30.     {
  31.         //document.getElementsByClassName("icon icon_next icon_size_XL")[0].click();
  32.         //document.querySelector('.player-controls__btn_next').click();
  33.         externalAPI.next();
  34.         /*var musicID = Math.floor(Math.random() * (20 - 0) + 0);
  35.         console.log('page loaded mid:'+musicID);
  36.         document.getElementsByClassName("icon icon_pp icon_size_L")[musicID].click();*/
  37.     }
  38.     else
  39.         setTimeout(wtf, 1000);
  40. }
  41.  
  42. function onload_ev()
  43. {
  44.     console.log("H EV LOADED");
  45.     /*var musicID = Math.floor(Math.random() * (20 - 0) + 0);
  46. console.log('page loaded mid:'+musicID);
  47. sleep(120000);
  48. document.getElementsByClassName("icon icon_pp icon_size_L")[musicID].click(); */
  49.     setTimeout(wtf(), 5000); //setTimeout isnt working
  50. }
  51.  
  52. window.onload = onload_ev;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement