Advertisement
Guest User

Untitled

a guest
Aug 14th, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Stop Automatic Recommendations on Soundcloud
  3. // @namespace   soundcloud-no-autoplay
  4. // @author      Veeno
  5. // @contributor Kai Kuehner
  6. // @contributor Technowise
  7. // @contributor Andreas J. Schwarz
  8. // @description Stops the automatic playing of recommended tracks on Soundcloud.
  9. // @include     http://www.soundcloud.com/*
  10. // @include     https://www.soundcloud.com/*
  11. // @include     http://soundcloud.com/*
  12. // @include     https://soundcloud.com/*
  13. // @grant       none
  14. // @version     1.3
  15. // ==/UserScript==
  16. //-------------------------------------------------------------------------------------------
  17. var sc_cp = {
  18.     "title": null,
  19.     "checkInterval": null,
  20.    
  21.     "titleElement": "a.playbackSoundBadge__context",
  22.     "attribute": "title",
  23.     "buttonElement": "button.playControl[title='Pause current']",
  24.    
  25.     "checkA": function () {
  26.         sc_cp.title = document.querySelector(sc_cp.titleElement).getAttribute(sc_cp.attribute);
  27.         if(sc_cp.title == null || sc_cp.title.substring(0, 28) != "Playing from recommendations") {
  28.             clearInterval(sc_cp.checkInterval);
  29.             sc_cp.checkInterval = setInterval(sc_cp.checkB, 100);
  30.         }
  31.     },
  32.    
  33.     "checkB": function () {
  34.         sc_cp.title = document.querySelector(sc_cp.titleElement).getAttribute(sc_cp.attribute);
  35.         if(sc_cp.title != null && sc_cp.title.substring(0, 28) == "Playing from recommendations") {
  36.             document.querySelector(sc_cp.buttonElement).click();
  37.             clearInterval(sc_cp.checkInterval);
  38.             sc_cp.checkInterval = setInterval(sc_cp.checkA, 500);
  39.         }
  40.     }
  41. };
  42.  
  43. window.onload = function() {
  44.     sc_cp.checkInterval = setInterval(sc_cp.checkA, 500);
  45. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement