dubtrack.fm autowoot

Automatically upvote songs when they play.

  1. // ==UserScript==
  2. // @name dubtrack.fm autowoot
  3. // @namespace https://greasyfork.org/en/users/13981-chk1
  4. // @include https://www.dubtrack.fm/join/*
  5. // @description Automatically upvote songs when they play.
  6. // @version 0.1
  7. // @grant none
  8. // @run-at document-end
  9. // ==/UserScript==
  10.  
  11. var config = {
  12. childList: true,
  13. attributes: true,
  14. subtree: true,
  15. attributeOldValue: true,
  16. characterData: true
  17. };
  18.  
  19. var currentSong, upvote;
  20.  
  21. var songObserver = new MutationObserver(function(mutations) {
  22. mutations.forEach(function(mutation) {
  23. if(mutation.type == "characterData" || mutation.type == "childList"){
  24. //console.log(mutation);
  25. upvote.click();
  26. }
  27. });
  28. });
  29.  
  30. function waitAndRegister() {
  31. window.setTimeout(function(){
  32. currentSong = document.querySelector('li.infoContainer span.currentSong');
  33. if(typeof(currentSong) == 'undefined') {
  34. waitAndRegister();
  35. } else {
  36. console.log('Songtitle element found');
  37. upvote = document.querySelector('a.dubup');
  38. songObserver.observe(currentSong, config);
  39. }
  40. }, 1000);
  41. };
  42. waitAndRegister();