Greasy Fork is available in English.

Special Events Script

allows sounds to be played for special events (eg. T-Spin Double)

  1. // ==UserScript==
  2. // @name Special Events Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.98
  5. // @description allows sounds to be played for special events (eg. T-Spin Double)
  6. // @author Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. Special Events Script
  13. **************************/
  14. (function() {
  15. window.addEventListener('load', function(){
  16.  
  17.  
  18. //set url to "" if you dont want an extra sound
  19. Game['eventSounds'] = [
  20. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_tspinsingle.mp3",
  21. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_tspinminisingle.mp3",
  22. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_clear1.wav",
  23. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_tspindouble.mp3",
  24. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_clear2.mp3",
  25. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_tspintriple.mp3",
  26. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_clear3.mp3",
  27. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_clear4.mp3",
  28. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_clear5.mp3",
  29. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_perfectclear.mp3",
  30. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_b2btspin.wav",
  31. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_b2btetris.mp3",
  32. //sound for incoming garbage (less than 4 lines), see bottom of script
  33. "",
  34. //sound for incoming garbage (4+ lines), see bottom of script
  35. ""
  36. ];
  37.  
  38. Game['eventVolumes'] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1]
  39.  
  40.  
  41. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  42. window.enableB2B = true;
  43.  
  44.  
  45. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  46. Game["eventSounds"].map((x,i)=>{
  47. if(Game['eventSounds'][i]){
  48. Game["sArray"].push(document.createElement("audio"));Game["sArray"][i].src=x
  49. }else {
  50. Game["sArray"].push(document.createElement("audio"));Game["sArray"][i].src="blank.wav"
  51. }
  52. })
  53.  
  54.  
  55. var evVol = document.createElement("tr");
  56. evVol.innerHTML = `Special Events vol:&nbsp;<input id="volControl3" oninput="localStorage.evVol=volControl3.value;volSetting3.innerHTML=volControl3.value+'%'" type="range" min="0" max="100" value="`+localStorage.evVol+`" step="1" style="width:150px;display:inline-block;padding-top:9px">&nbsp;&nbsp;<span id="volSetting3">`+localStorage.evVol+`%</span>`
  57. tab_sound.appendChild(evVol);
  58.  
  59. if(typeof playSound != 'function') {
  60. window.playSound = function(S){s=Game.sArray[S];console.log(s);!s.paused&&0<s.currentTime?s.currentTime=0:(s.volume=Game['eventVolumes'][S]*localStorage.evVol/100,s.play())}
  61. }
  62.  
  63.  
  64. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  65.  
  66. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  67. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  68.  
  69.  
  70. var clcFunc = Game['prototype']['checkLineClears'].toString()
  71. var clcParams = getParams(clcFunc)
  72. searchFor = "[_" + clcFunc.split("switch")[1].split("]][_")[2]
  73.  
  74. events.map((x,i)=>{
  75. replacement = searchFor.replace("[","[Game['btb']=this['isBack2Back'],console.log('"+x+"'),Game['latestEv']='"+x+"',")
  76. clcFunc=clcFunc.replace(searchFor,replacement)
  77. })
  78.  
  79. Game['prototype']["checkLineClears"] = new Function(...clcParams, trim(clcFunc));
  80.  
  81. var psFunc = Game['prototype']['playSound'].toString()
  82. var psParams = getParams(psFunc);
  83. psFunc = `
  84. if(Game["latestEv"]){
  85. sIndex=events.indexOf(Game["latestEv"]);
  86. console.log(sIndex)
  87. sound=sIndex;enableB2B&&Game.btb&&~[0,1,3,5,7,8].indexOf(sIndex)&&(sound=10+ +(7==sIndex));
  88. console.log(sound);
  89. Game.sArray[sound]&&playSound(sound);
  90. Game["latestEv"]="";
  91. }` + trim(psFunc)
  92.  
  93. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  94.  
  95. localStorage.mainVol = localStorage.mainVol || "100"
  96. document.getElementById("settingsSave").addEventListener("click", function(){
  97. localStorage.mainVol=document.getElementById('vol-control').value
  98. }, false);
  99.  
  100. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  101.  
  102.  
  103.  
  104.  
  105. //Sounds for incoming garbage
  106. var garbageFunc = Game['prototype']['addGarbage'].toString()
  107. var garbageParams = getParams(garbageFunc)
  108. garbageFunc = garbageFunc.replace("}","};playSound(12+ +("+garbageParams+">4));");
  109. Game['prototype']["addGarbage"] = new Function(...garbageParams, trim(garbageFunc));
  110.  
  111.  
  112.  
  113. });
  114. })();