apajohnson

Untitled

Aug 7th, 2014
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. // ==UserScript==
  2. // @name NewCompte TagPro Volume slider
  3. // @namespace http://www.reddit.com/user/NewCompte
  4. // @description Adds a volume slider to TagPro
  5. // @include http://tagpro-*.koalabeast.com*
  6. // @license WTFPL
  7. // @author NewCompte
  8. // @version 0.3
  9. // ==/UserScript==
  10.  
  11. function myScript()
  12. {
  13. tagpro.ready( function () {
  14. setTimeout( function () {
  15. var oldsound = tagpro.playSound;
  16. tagpro.playSound = function (s, v) {
  17. oldsound(s, v * tagpro.globalvolume);
  18. };
  19. }, 500);
  20. });
  21. function changeVolume (value, s, v)
  22. {
  23. tagpro.globalvolume = Math.pow(10, value/20);
  24. tagpro.playSound(s, v);
  25. localStorage.setItem("volume", value);
  26. }
  27. var volumerange = document.getElementById("volume");
  28. volumerange.value = (localStorage.getItem("volume") || 0) * 1;
  29. tagpro.globalvolume = Math.pow(10, volumerange.value/20);
  30. volumerange.addEventListener("change", function () {changeVolume(volumerange.value, "click", 0.5); });
  31. volumerange.addEventListener("mouseup", function () {changeVolume(volumerange.value, "pop", 1); });
  32. }
  33.  
  34. var volumerange = document.createElement('input');
  35. volumerange.value = 0;
  36.  
  37. volumerange.type = "range";
  38. volumerange.id = "volume";
  39. volumerange.min = -30;
  40. volumerange.max = 0;
  41. volumerange.style.width ="64px";
  42. document.getElementById("sound").appendChild(volumerange);
  43.  
  44. var source = "(" + myScript + ")()";
  45. var thescript = document.createElement('script');
  46. thescript.setAttribute("type", "application/javascript");
  47. thescript.textContent = source;
  48.  
  49. document.body.appendChild(thescript);
Add Comment
Please, Sign In to add comment