Magical (TF) Theme

Tetris Friends Magical SFX for Jstris

  1. // ==UserScript==
  2. // @name Magical (TF) Theme
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.53
  5. // @description Tetris Friends Magical SFX for Jstris
  6. // @author Oki, Eddie, Bang
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. window.addEventListener('load', function(){
  16.  
  17. //Jstris Block Skin Change
  18. loadSkin("https://i.imgur.com/ofXpOFG.png",36);
  19. loadGhostSkin("https://i.imgur.com/R76ixGK.png",36);
  20.  
  21. //Jstris Custom Background Image
  22. document.head.getElementsByTagName("style")[0].innerHTML="";
  23. document.body.style.backgroundImage="url('https://i.pinimg.com/originals/9e/d4/ff/9ed4ff2865fd3bd64b17003e65168dff.jpg')";
  24. document.body.style.backgroundSize="100% 100%";
  25. document.getElementById("app").style.backgroundColor="rgba(0, 0, 0, 0.5)";
  26. document.getElementById("app").style.height="1000px";
  27.  
  28.  
  29. //Jstris SFX
  30. CustomSFXset.prototype = new BaseSFXset;
  31. loadSFX(new CustomSFXset);
  32.  
  33. });
  34. })();
  35.  
  36. function CustomSFXset(){
  37. this.volume=1;
  38. this.lock={url:"https://www.dropbox.com/s/vs3j3dbqfvbo6wf/fx_hrddp.mp3?dl=1",abs:1};
  39. this.ready={url:"https://www.dropbox.com/s/vqfgn4fy20e5mu0/fx_01tic.mp3?dl=1",abs:1,set:1};
  40. this.go={url:"https://www.dropbox.com/s/1oul81pr9ff2zl3/fx_go.mp3?dl=1",abs:1,set:0};
  41. this.died={url:"https://www.dropbox.com/s/ru0212t1wyfxqyx/fx_lose.mp3?dl=1",abs:1,set:1};
  42. this.hold={url:"https://www.dropbox.com/s/npd5d9ahf5dnpr3/fx_hold.mp3?dl=1",abs:1,set:0};
  43. this.move={url:"https://www.dropbox.com/s/liuqi5uxbnwlxl4/fx_move.mp3?dl=1",abs:1,set:0};
  44. this.linefall={url:"blank.wav",abs:1,set:0};
  45. this.comboTones={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Magiccombo.mp3",abs:1,set:2,duration:4500,spacing:500,cnt:8};
  46. };
  47.  
  48. /**************************
  49. Special Events Script
  50. **************************/
  51. (function() {
  52. window.addEventListener('load', function(){
  53.  
  54. Game['eventSounds'] = [
  55. "https://www.dropbox.com/s/vk40rz8slztlf11/vo_tspinsingle.mp3?dl=1",
  56. "https://www.dropbox.com/s/vr5jdb4d9r2yidu/vo_tspinmini.mp3?dl=1",
  57. "https://ecdldaiiere.github.io/Eddiez-Soundz/8bit_clear1.mp3", //no sound exists for TF
  58. "https://www.dropbox.com/s/yugu0mpwfymi1ym/vo_tspindouble.mp3?dl=1",
  59. "https://www.dropbox.com/s/3zov7z53anr4op3/vo_lne02.mp3?dl=1",
  60. "https://www.dropbox.com/s/xibqdg62hsr9xw1/vo_lne03.mp3?dl=1",
  61. "https://www.dropbox.com/s/wjqqhcgkfysrw2i/vo_tspintriple.mp3?dl=1",
  62. "https://www.dropbox.com/s/lsp7jx7anilgzqe/vo_tetrs.mp3?dl=1",
  63. "https://ecdldaiiere.github.io/Eddiez-Soundz/8bit_perfectclear.mp3", //no sound exists for TF
  64. "https://www.dropbox.com/s/5pn4kt3fp49tmog/vo_b2btetrs.mp3?dl=1",
  65. "https://www.dropbox.com/s/7zk9c3gesenx76y/vo_b2btetrs.mp3?dl=1"
  66.  
  67. ];
  68.  
  69. Game['eventVolumes'] = [1,1,1,1,1,1,1,1,1,1,1]
  70.  
  71.  
  72. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","PERFECT_CLEAR"]
  73. window.enableB2B = true;
  74.  
  75.  
  76. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  77. 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)}})
  78.  
  79.  
  80. var evVol = document.createElement("tr");
  81. 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>`
  82. tab_sound.appendChild(evVol);
  83.  
  84. if(typeof playSound != 'function') {
  85. 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())}
  86. }
  87.  
  88.  
  89. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","PERFECT_CLEAR"]
  90.  
  91. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  92. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  93.  
  94.  
  95. var clcFunc = Game['prototype']['checkLineClears'].toString()
  96. var clcParams = getParams(clcFunc)
  97. searchFor = "[_" + clcFunc.split("switch")[1].split("]][_")[2]
  98.  
  99. events.map((x,i)=>{
  100. replacement = searchFor.replace("[","[Game['btb']=this['isBack2Back'],Game['latestEv']='"+x+"',")
  101. clcFunc=clcFunc.replace(searchFor,replacement)
  102. })
  103.  
  104. Game['prototype']["checkLineClears"] = new Function(...clcParams, trim(clcFunc));
  105.  
  106. var psFunc = Game['prototype']['playSound'].toString()
  107. var psParams = getParams(psFunc);
  108. psFunc = 'if(Game["latestEv"]){sIndex=events.indexOf(Game["latestEv"]);sound=sIndex;enableB2B&&Game.btb&&~[0,1,3,5,7].indexOf(sIndex)&&(sound=9+ +(7==sIndex));console.log(sound);Game.sArray[sound]&&playSound(sound);Game["latestEv"]="";}' + trim(psFunc)
  109. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  110.  
  111. localStorage.mainVol = localStorage.mainVol || "100"
  112. document.getElementById("settingsSave").addEventListener("click", function(){
  113. localStorage.mainVol=document.getElementById('vol-control').value
  114. }, false);
  115.  
  116. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  117.  
  118. /**************************
  119. Rotation Sounds Script
  120. **************************/
  121.  
  122. Game['rotationSounds'] = [
  123. "https://www.dropbox.com/s/s7sc4knyddjv6vh/fx_rta01.mp3?dl=1", //rotate left
  124. "https://www.dropbox.com/s/s7sc4knyddjv6vh/fx_rta01.mp3?dl=1", //rotate right
  125. "https://www.dropbox.com/s/s7sc4knyddjv6vh/fx_rta01.mp3?dl=1" //rotate 180°
  126. ];
  127.  
  128. Game['rotationVolumes'] = [1,1,1]
  129.  
  130. localStorage.evVol=localStorage.evVol||"100"
  131.  
  132. Game["rArray"]=[];
  133. 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)}})
  134.  
  135.  
  136. 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())}
  137.  
  138.  
  139. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  140. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  141.  
  142. var rotFunc = Game['prototype']['rotateCurrentBlock'].toString()
  143. var rotParams = getParams(rotFunc)
  144.  
  145. var rotInsert = 'var rotPos=[0,0,1,2]['+rotParams[0]+'+1];console.log(rotPos);Game.rArray[rotPos]&&playRotSound(rotPos);'
  146.  
  147. rotFunc = rotInsert + trim(rotFunc)
  148.  
  149. Game['prototype']['rotateCurrentBlock'] = new Function(...rotParams, rotFunc);
  150.  
  151.  
  152. /**************************
  153. Songs Script
  154. **************************/
  155.  
  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. localStorage.musicVol = localStorage.musicVol || "100";
  162. localStorage.SPvol = localStorage.SPvol || "100";
  163.  
  164. var musicVol = document.createElement("tr");
  165. 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>'
  166. tab_sound.appendChild(musicVol);
  167.  
  168. var spVol = document.createElement("tr");
  169. 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>'
  170. tab_sound.appendChild(spVol);
  171.  
  172.  
  173.  
  174. Game["setVol"] = function(vol,mode) {
  175. if(mode){
  176. localStorage.musicVol = vol
  177. volSetting.innerHTML=vol+'%';
  178. var musicVol=document.getElementById("volControl")
  179. Game["songs"].map(x=>{
  180. x.volume = (musicVol.value/100);
  181. })
  182. } else {
  183. localStorage.SPvol = vol
  184. volSetting2.innerHTML=vol+'%';
  185. var spVol=document.getElementById("volControl2")
  186. Game["song"].volume = spVol.value/100
  187. }
  188. }
  189.  
  190.  
  191. if(typeof Game != "undefined"){
  192.  
  193.  
  194. var songsMP = [
  195. "https://www.dropbox.com/s/luyvroqji6wqn5m/Final%20Fantasy%20Mystic%20Quest%20Battle%20Theme.mp3?dl=1",
  196. ]
  197.  
  198. var songSP = "https://www.dropbox.com/s/luyvroqji6wqn5m/Final%20Fantasy%20Mystic%20Quest%20Battle%20Theme.mp3?dl=1"
  199.  
  200. var songThresholds = [1]
  201.  
  202. Game['onlySprint'] = true;
  203.  
  204.  
  205. window.playSong = function(s) {
  206. Game["songs"].map(x=>{
  207. x.pause();
  208. x.currentTime = 0;
  209. })
  210. Game["song"].pause();
  211. Game["song"].currentTime = 0;
  212.  
  213. if(s != undefined){
  214. !s.paused&&0<s.currentTime?s.currentTime=0:s.play()
  215. }
  216. }
  217.  
  218. Game["songs"] = [];
  219. Game["maxPlayers"] = 0
  220. Game["songIndex"] = -1
  221.  
  222.  
  223. Game["song"] = document.createElement("audio");
  224. Game["song"].src = songSP;
  225. Game["song"].loop = true;
  226. Game["song"].volume = 1;
  227.  
  228. songsMP.map((x,i)=>{
  229. Game["songs"].push(document.createElement("audio"));
  230. Game["songs"][i].src = x;
  231. Game["songs"][i].loop = true;
  232. Game["songs"][i].volume = 1;
  233. })
  234.  
  235. Game["setVol"](localStorage.musicVol,1)
  236. Game["setVol"](localStorage.SPvol,0)
  237.  
  238.  
  239. Game["updateSong"] = function(i) {
  240.  
  241. if(i<0){
  242. Game["maxPlayers"] = 0
  243. playSong()
  244. Game["songIndex"] = -1
  245. }
  246.  
  247. if(i==0){
  248. Game["maxPlayers"]= -1
  249. playSong(Game["songs"][0])
  250. Game["songIndex"] = 0
  251. }
  252.  
  253. if(typeof i == "string"){
  254. if(Game["maxPlayers"]<0){
  255. Game["maxPlayers"]=parseInt(i)
  256. }
  257. var alivePercent = (parseInt(i)-1)/Game["maxPlayers"]
  258. if(alivePercent <= songThresholds[Game["songIndex"]+1]){
  259. console.log(Game["songIndex"])
  260. Game["songIndex"]++
  261. playSong(Game["songs"][Game["songIndex"]])
  262. }
  263. }
  264.  
  265. }
  266.  
  267. var gameOver99 = Game['prototype']['GameOver'].toString();
  268. gameOver99 = "Game['updateSong'](-1);Game['song'].pause();Game['song'].currentTime=0;" + trim(gameOver99)
  269. Game['prototype']['GameOver'] = new Function(gameOver99)
  270.  
  271. var printSlot99 = SlotView['prototype']['printSlotPlace'].toString()
  272. var printSlotParams = getParams(printSlot99);
  273. printSlot99 = `Game["updateSong"](this['slot']['gs']['p']['getPlaceColor'](${printSlotParams[0]})['str']);` + trim(printSlot99)
  274. SlotView['prototype']['printSlotPlace'] = new Function(...printSlotParams, printSlot99);
  275.  
  276.  
  277.  
  278. var readyGo99 = Game['prototype']['restart'].toString()
  279. 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)
  280. Game['prototype']['restart'] = new Function(readyGo99);
  281.  
  282. var specMode99 = Live['prototype']['spectatorMode'].toString()
  283. var specParams = getParams(specMode99);
  284. specMode99 = `Game['updateSong'](-1);` + trim(specMode99)
  285. Live['prototype']['spectatorMode'] = new Function(...specParams, specMode99);
  286.  
  287. var paint99 = Game['prototype']['paintMatrixWithColor'].toString()
  288. var paintParams = getParams(paint99);
  289. paint99 = `Game['updateSong'](-1);` + trim(paint99)
  290. Game['prototype']['paintMatrixWithColor'] = new Function(...paintParams, paint99);
  291.  
  292. localStorage.mainVol = localStorage.mainVol || "100"
  293. document.getElementById("settingsSave").addEventListener("click", function(){localStorage.mainVol=document.getElementById('vol-control').value}, false);
  294. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  295.  
  296.  
  297. //remove these 3 lines if you dont want the music to stop for the countdown
  298. var readyGo992 = Game['prototype']['readyGo'].toString()
  299. readyGo992 = "Game['updateSong'](-1);" + trim(readyGo992)
  300. Game['prototype']['readyGo'] = new Function(readyGo992);
  301. }
  302.  
  303. });
  304. })();