Nullpomino Theme

Nullpomino Theme for Jstris

  1. // ==UserScript==
  2. // @name Nullpomino Theme
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.25
  5. // @description Nullpomino Theme for Jstris
  6. // @author Eddie, Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.  
  14. function CustomSFXset(){
  15. this.volume=1;
  16. this.lock={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/blank.wav",abs:1};
  17. this.ready={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_ready.wav",abs:1,set:1};
  18. this.go={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_go.wav",abs:1,set:0};
  19. this.died={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_died.wav",abs:1,set:1};
  20. this.hold={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_hold.wav",abs:1,set:0};
  21. this.move={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_move.wav",abs:1,set:0};
  22. this.linefall={url:"blank.wav",abs:1,set:0};
  23. this.comboTones={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpocombofixed.mp3",abs:1,set:2,duration:1000,spacing:500,cnt:21};
  24. };
  25.  
  26. window.addEventListener('load', function(){
  27.  
  28. //Next Piece Sounds
  29. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  30. Game['pieceSoundsTGM'] = [];
  31. var srcs = [
  32. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_i.wav",
  33. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_o.wav",
  34. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_t.wav",
  35. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_l.wav",
  36. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_j.wav",
  37. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_s.wav",
  38. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_z.wav",
  39. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_idk.wav"
  40. ];
  41.  
  42. Game['playSoundTGM'] = function(s)
  43. {
  44. if (!s.paused && s.currentTime > 0)
  45. {
  46. s.currentTime = 0;
  47. }
  48. else s.play();
  49. }
  50.  
  51. function a(s, b)
  52. {
  53. for (var i = 0; i < b.length; i++)
  54. {
  55. s.push(document.createElement("audio"));
  56. s[i].src = b[i];
  57. s[i].volume = 0.8;
  58. }
  59. }
  60. a(Game['pieceSoundsTGM'], srcs);
  61.  
  62.  
  63. var uqbFunc = Game['prototype']['updateQueueBox'].toString()
  64. uqbFunc = "Game['playSoundTGM'](Game['pieceSoundsTGM'][this.queue[0].id]);" + trim(uqbFunc)
  65. Game['prototype']['updateQueueBox'] = new Function(uqbFunc);
  66.  
  67. //Jstris SFX
  68. CustomSFXset.prototype = new BaseSFXset;
  69. loadSFX(new CustomSFXset);
  70.  
  71. //Jstris Block Skin Change
  72. loadSkin("https://i.imgur.com/zln5qf5.png",32);
  73. loadGhostSkin("https://i.imgur.com/zyeqsgp.png",32);
  74.  
  75. //Jstris Custom Background Image
  76. document.head.getElementsByTagName("style")[0].innerHTML="";
  77. document.body.style.backgroundImage="url('https://i.imgur.com/8voPxzQ.png)";
  78. document.body.style.backgroundSize="100%";
  79. document.getElementById("app").style.backgroundColor="rgba(0, 0, 0, 0)";
  80. document.getElementById("app").style.height="1000px";
  81.  
  82.  
  83. /**************************
  84. Rotation Sounds Script
  85. **************************/
  86.  
  87. Game['rotationSounds'] = [
  88. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_rotate.wav", //rotate left
  89. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_rotate.wav", //rotate right
  90. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_rotate.wav" //rotate 180°
  91. ];
  92.  
  93. Game['rotationVolumes'] = [1,1,1]
  94.  
  95. localStorage.evVol=localStorage.evVol||"100"
  96.  
  97. Game["rArray"]=[];
  98. Game["rotationSounds"].map((x,i)=>{if(Game['rotationSounds'][i]){Game["rArray"].push(document.createElement("audio"));Game["rArray"][i].src=x}else{Game["rArray"].push(null)}})
  99.  
  100.  
  101. window.playRotSound = function(S){s=Game.rArray[S];!s.paused&&0<s.currentTime?s.currentTime=0:(s.volume=Game['rotationVolumes'][S]*localStorage.evVol/100,s.play())}
  102.  
  103.  
  104. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  105. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  106.  
  107. var rotFunc = Game['prototype']['rotateCurrentBlock'].toString()
  108. var rotParams = getParams(rotFunc)
  109.  
  110. var rotInsert = 'var rotPos=[0,0,1,2]['+rotParams[0]+'+1];console.log(rotPos);Game.rArray[rotPos]&&playRotSound(rotPos);'
  111.  
  112. rotFunc = rotInsert + trim(rotFunc)
  113.  
  114. Game['prototype']['rotateCurrentBlock'] = new Function(...rotParams, rotFunc);
  115.  
  116.  
  117. /**************************
  118. Special Events Script
  119. **************************/
  120. Game['eventSounds'] = [
  121. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_tspinsingle.wav",
  122. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_tspinmini.wav",
  123. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_clear1.wav",
  124. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_tspindouble.wav",
  125. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_clear2.wav",
  126. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_clear3.wav",
  127. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_tspintriple.wav",
  128. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_clear4.wav",
  129. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_clear5.mp3",
  130. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_perfectclear.wav",
  131. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_b2btspin.mp3",
  132. "https://ecdldaiiere.github.io/Eddiez-Soundz/Nullpo_b2btetris.mp3"
  133. ];
  134.  
  135. Game['eventVolumes'] = [1,1,1,1,1,1,1,1,1,1,1,1]
  136.  
  137.  
  138. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  139. window.enableB2B = true;
  140.  
  141.  
  142. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  143. Game["eventSounds"].map((x,i)=>{if(Game['eventSounds'][i]){Game["sArray"].push(document.createElement("audio"));Game["sArray"][i].src=x}else{Game["sArray"].push(null)}})
  144.  
  145.  
  146. var evVol = document.createElement("tr");
  147. 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>`
  148. tab_sound.appendChild(evVol);
  149.  
  150. if(typeof playSound != 'function') {
  151. 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())}
  152. }
  153.  
  154.  
  155. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  156.  
  157. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  158. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  159.  
  160.  
  161. var clcFunc = Game['prototype']['checkLineClears'].toString()
  162. var clcParams = getParams(clcFunc)
  163. searchFor = "[_" + clcFunc.split("switch")[1].split("]][_")[2]
  164.  
  165. events.map((x,i)=>{
  166. replacement = searchFor.replace("[","[Game['btb']=this['isBack2Back'],console.log('"+x+"'),Game['latestEv']='"+x+"',")
  167. clcFunc=clcFunc.replace(searchFor,replacement)
  168. })
  169.  
  170. Game['prototype']["checkLineClears"] = new Function(...clcParams, trim(clcFunc));
  171.  
  172. var psFunc = Game['prototype']['playSound'].toString()
  173. var psParams = getParams(psFunc);
  174. psFunc = `
  175. if(Game["latestEv"]){
  176. sIndex=events.indexOf(Game["latestEv"]);
  177. console.log(sIndex)
  178. sound=sIndex;enableB2B&&Game.btb&&~[0,1,3,5,7,8].indexOf(sIndex)&&(sound=10+ +(7==sIndex));
  179. console.log(sound);
  180. Game.sArray[sound]&&playSound(sound);
  181. Game["latestEv"]="";
  182. }` + trim(psFunc)
  183.  
  184. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  185.  
  186. localStorage.mainVol = localStorage.mainVol || "100"
  187. document.getElementById("settingsSave").addEventListener("click", function(){
  188. localStorage.mainVol=document.getElementById('vol-control').value
  189. }, false);
  190.  
  191. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  192.  
  193.  
  194. }
  195.  
  196. )();
  197. })();