Greasy Fork is available in English.

TETR.IO Theme

TETR.IO Theme for Jstris

  1. // ==UserScript==
  2. // @name TETR.IO Theme
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.19
  5. // @description TETR.IO Theme for Jstris
  6. // @author Eddie, NueSB, Oki, OSK
  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/Tetrio_lock.mp3",abs:1};
  17. this.ready={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/goodluckyready.mp3",abs:1,set:1};
  18. this.go={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/goodluckygo.mp3",abs:1,set:0};
  19. this.died={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_died.mp3",abs:1,set:1};
  20. this.hold={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_hold.mp3",abs:1,set:0};
  21. this.move={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_move.mp3",abs:1,set:0};
  22. this.linefall={url:"blank.wav",abs:1,set:0};
  23. this.comboTones={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_combo.mp3",abs:1,set:2,duration:1000,spacing:500,cnt:17};
  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/goodlucky_imino.mp3",
  33. "https://ecdldaiiere.github.io/Eddiez-Soundz/goodlucky_omino.mp3",
  34. "https://ecdldaiiere.github.io/Eddiez-Soundz/goodlucky_tmino.mp3",
  35. "https://ecdldaiiere.github.io/Eddiez-Soundz/goodlucky_lmino.mp3",
  36. "https://ecdldaiiere.github.io/Eddiez-Soundz/goodlucky_jmino.mp3",
  37. "https://ecdldaiiere.github.io/Eddiez-Soundz/goodlucky_smino.mp3",
  38. "https://ecdldaiiere.github.io/Eddiez-Soundz/goodlucky_zmino.mp3",
  39. "https://ecdldaiiere.github.io/Eddiez-Soundz/goodlucky_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.43;
  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/XcnWlC6.png",30);
  73. loadGhostSkin("https://i.imgur.com/f7kvOMi.png",30);
  74.  
  75. //Jstris Custom Background Image
  76. document.head.getElementsByTagName("style")[0].innerHTML="";
  77. document.body.style.backgroundImage="url('https://i.imgur.com/tgQkAX5.jpg)";
  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/Tetrio_rotate.mp3", //rotate left
  89. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_rotate.mp3", //rotate right
  90. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_rotate.mp3" //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. Songs Script
  118. **************************/
  119.  
  120. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  121. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  122.  
  123.  
  124. localStorage.musicVol = localStorage.musicVol || "100";
  125. localStorage.SPvol = localStorage.SPvol || "100";
  126.  
  127. var musicVol = document.createElement("tr");
  128. musicVol.innerHTML = 'Music vol (MP):&nbsp;<input id="volControl" oninput="Game.setVol(volControl.value,1)" type="range" min="0" max="100" value="'+localStorage.musicVol+'" step="1" style="width:150px;display:inline-block;padding-top:9px">&nbsp;&nbsp;<span id="volSetting">'+localStorage.musicVol+'%</span>'
  129. tab_sound.appendChild(musicVol);
  130.  
  131. var spVol = document.createElement("tr");
  132. spVol.innerHTML = 'Music vol (SP):&nbsp;<input id="volControl2" oninput="Game.setVol(volControl2.value,0)" type="range" min="0" max="100" value="'+localStorage.SPvol+'" step="1" style="width:150px;display:inline-block;padding-top:9px">&nbsp;&nbsp;<span id="volSetting2">'+localStorage.SPvol+'%</span>'
  133. tab_sound.appendChild(spVol);
  134.  
  135.  
  136.  
  137. Game["setVol"] = function(vol,mode) {
  138. if(mode){
  139. localStorage.musicVol = vol
  140. volSetting.innerHTML=vol+'%';
  141. var musicVol=document.getElementById("volControl")
  142. Game["songs"].map(x=>{
  143. x.volume = (musicVol.value/100);
  144. })
  145. } else {
  146. localStorage.SPvol = vol
  147. volSetting2.innerHTML=vol+'%';
  148. var spVol=document.getElementById("volControl2")
  149. Game["song"].volume = spVol.value/100
  150. }
  151. }
  152.  
  153.  
  154. if(typeof Game != "undefined"){
  155.  
  156.  
  157. var songsMP = [
  158. "https://ecdldaiiere.github.io/Eddiez-Soundz/hangingoutintokyo.mp3",
  159. "https://ecdldaiiere.github.io/Eddiez-Soundz/hangingoutintokyo.mp3",
  160. "https://ecdldaiiere.github.io/Eddiez-Soundz/hangingoutintokyo.mp3"
  161. ]
  162.  
  163. var songSP = "https://ecdldaiiere.github.io/Eddiez-Soundz/piercingwind.mp3"
  164.  
  165. //Play song when only X*100% of players are left (first one is always 1)
  166. var songThresholds = [1, 0.6, 0.2]
  167.  
  168. Game['onlySprint'] = false;
  169.  
  170.  
  171. window.playSong = function(s) {
  172. Game["songs"].map(x=>{
  173. x.pause();
  174. x.currentTime = 0;
  175. })
  176. Game["song"].pause();
  177. Game["song"].currentTime = 0;
  178.  
  179. if(s != undefined){
  180. !s.paused&&0<s.currentTime?s.currentTime=0:s.play()
  181. }
  182. }
  183.  
  184. Game["songs"] = [];
  185. Game["maxPlayers"] = 0
  186. Game["songIndex"] = -1
  187.  
  188.  
  189. Game["song"] = document.createElement("audio");
  190. Game["song"].src = songSP;
  191. Game["song"].loop = true;
  192. Game["song"].volume = 1;
  193.  
  194. songsMP.map((x,i)=>{
  195. Game["songs"].push(document.createElement("audio"));
  196. Game["songs"][i].src = x;
  197. Game["songs"][i].loop = true;
  198. Game["songs"][i].volume = 1;
  199. })
  200.  
  201. Game["setVol"](localStorage.musicVol,1)
  202. Game["setVol"](localStorage.SPvol,0)
  203.  
  204.  
  205. Game["updateSong"] = function(i) {
  206.  
  207. if(i<0){
  208. Game["maxPlayers"] = 0
  209. playSong()
  210. Game["songIndex"] = -1
  211. }
  212.  
  213. if(i==0){
  214. Game["maxPlayers"]= -1
  215. playSong(Game["songs"][0])
  216. Game["songIndex"] = 0
  217. }
  218.  
  219. if(typeof i == "string"){
  220. if(Game["maxPlayers"]<0){
  221. Game["maxPlayers"]=parseInt(i)
  222. }
  223. var alivePercent = (parseInt(i)-1)/Game["maxPlayers"]
  224. if(alivePercent <= songThresholds[Game["songIndex"]+1]){
  225. console.log(Game["songIndex"])
  226. Game["songIndex"]++
  227. playSong(Game["songs"][Game["songIndex"]])
  228. }
  229. }
  230.  
  231. }
  232.  
  233. var gameOver99 = Game['prototype']['GameOver'].toString();
  234. gameOver99 = "Game['updateSong'](-1);Game['song'].pause();Game['song'].currentTime=0;" + trim(gameOver99)
  235. Game['prototype']['GameOver'] = new Function(gameOver99)
  236.  
  237. var printSlot99 = SlotView['prototype']['printSlotPlace'].toString()
  238. var printSlotParams = getParams(printSlot99);
  239. printSlot99 = `Game["updateSong"](this['slot']['gs']['p']['getPlaceColor'](${printSlotParams[0]})['str']);` + trim(printSlot99)
  240. SlotView['prototype']['printSlotPlace'] = new Function(...printSlotParams, printSlot99);
  241.  
  242.  
  243.  
  244. var readyGo99 = Game['prototype']['restart'].toString()
  245. readyGo99 = "if(this['pmode']+this['isPmode'](true)+this['isPmode'](false)==0){Game['updateSong'](0)}else{Game['updateSong'](-1);if(!Game['onlySprint']){playSong(Game['song'])}else{if(this['pmode']==1){playSong(Game['song'])}}};" + trim(readyGo99)
  246. Game['prototype']['restart'] = new Function(readyGo99);
  247.  
  248. var specMode99 = Live['prototype']['spectatorMode'].toString()
  249. var specParams = getParams(specMode99);
  250. specMode99 = `Game['updateSong'](-1);` + trim(specMode99)
  251. Live['prototype']['spectatorMode'] = new Function(...specParams, specMode99);
  252.  
  253. var paint99 = Game['prototype']['paintMatrixWithColor'].toString()
  254. var paintParams = getParams(paint99);
  255. paint99 = `Game['updateSong'](-1);` + trim(paint99)
  256. Game['prototype']['paintMatrixWithColor'] = new Function(...paintParams, paint99);
  257.  
  258.  
  259. localStorage.mainVol = localStorage.mainVol || "100"
  260. document.getElementById("settingsSave").addEventListener("click", function(){localStorage.mainVol=document.getElementById('vol-control').value}, false);
  261. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  262.  
  263. //remove these 3 lines if you dont want the music to stop for the countdown
  264. var readyGo992 = Game['prototype']['readyGo'].toString()
  265. readyGo992 = "Game['updateSong'](-1);" + trim(readyGo992)
  266. Game['prototype']['readyGo'] = new Function(readyGo992);
  267. }
  268.  
  269.  
  270. /**************************
  271. Special Events Script
  272. **************************/
  273. Game['eventSounds'] = [
  274. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_tspinsingle.mp3",
  275. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_tspinsingle.mp3",
  276. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_clear1.mp3",
  277. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_tspindouble.mp3",
  278. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_clear2.mp3",
  279. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_clear3.mp3",
  280. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_tspintriple.mp3",
  281. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_clear4.mp3",
  282. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_clear5.mp3",
  283. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_perfectclear.mp3",
  284. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_tspindouble.mp3",
  285. "https://ecdldaiiere.github.io/Eddiez-Soundz/Tetrio_b2btetris.mp3"
  286. ];
  287.  
  288. Game['eventVolumes'] = [1,1,1,1,1,1,1,1,1,1,1,1]
  289.  
  290.  
  291. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  292. window.enableB2B = true;
  293.  
  294.  
  295. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  296. 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)}})
  297.  
  298.  
  299. var evVol = document.createElement("tr");
  300. 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>`
  301. tab_sound.appendChild(evVol);
  302.  
  303. if(typeof playSound != 'function') {
  304. 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())}
  305. }
  306.  
  307.  
  308. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  309.  
  310. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  311. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  312.  
  313.  
  314. var clcFunc = Game['prototype']['checkLineClears'].toString()
  315. var clcParams = getParams(clcFunc)
  316. searchFor = "[_" + clcFunc.split("switch")[1].split("]][_")[2]
  317.  
  318. events.map((x,i)=>{
  319. replacement = searchFor.replace("[","[Game['btb']=this['isBack2Back'],console.log('"+x+"'),Game['latestEv']='"+x+"',")
  320. clcFunc=clcFunc.replace(searchFor,replacement)
  321. })
  322.  
  323. Game['prototype']["checkLineClears"] = new Function(...clcParams, trim(clcFunc));
  324.  
  325. var psFunc = Game['prototype']['playSound'].toString()
  326. var psParams = getParams(psFunc);
  327. psFunc = `
  328. if(Game["latestEv"]){
  329. sIndex=events.indexOf(Game["latestEv"]);
  330. console.log(sIndex)
  331. sound=sIndex;enableB2B&&Game.btb&&~[0,1,3,5,7,8].indexOf(sIndex)&&(sound=10+ +(7==sIndex));
  332. console.log(sound);
  333. Game.sArray[sound]&&playSound(sound);
  334. Game["latestEv"]="";
  335. }` + trim(psFunc)
  336.  
  337. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  338.  
  339. localStorage.mainVol = localStorage.mainVol || "100"
  340. document.getElementById("settingsSave").addEventListener("click", function(){
  341. localStorage.mainVol=document.getElementById('vol-control').value
  342. }, false);
  343.  
  344. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  345.  
  346.  
  347. }
  348.  
  349. )();
  350. })();