The Ultimate Jstris Script

Multiple script code in one script

  1. // ==UserScript==
  2. // @name The Ultimate Jstris Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.33
  5. // @description Multiple script code in one script
  6. // @author MattMayuga, Oki, Eddie
  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. //Jstris Custom Background Image
  17. document.head.getElementsByTagName("style")[0].innerHTML="";
  18. document.body.style.backgroundImage="url('https://cdn.discordapp.com/attachments/263058966869835776/583234690736062474/img_visual.png')";
  19. document.body.style.backgroundSize="100%";
  20. document.getElementById("app").style.backgroundColor="rgba(0, 0, 0, 0.8)";
  21. document.getElementById("app").style.height="1000px";
  22.  
  23. //Jstris Block Skin Change
  24. loadSkin("https://i.imgur.com/T7PyM45.png",32);
  25. loadGhostSkin("https://i.imgur.com/OvH7LA4.png",36);
  26.  
  27. //Jstris SFX
  28. CustomSFXset.prototype = new BaseSFXset;
  29. loadSFX(new CustomSFXset);
  30.  
  31. });
  32. })();
  33.  
  34. function CustomSFXset(){
  35. this.volume=1;
  36. this.lock={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/t99lock.wav",abs:1};
  37. this.ready={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/t99ready.wav",abs:1,set:1};
  38. this.go={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/t99go.wav",abs:1,set:0};
  39. this.died={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/t99died.wav",abs:1,set:1};
  40. this.hold={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/t99hold.wav",abs:1,set:0};
  41. this.move={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/t99move.wav",abs:1,set:0};
  42. this.comboTones={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Hancombo.mp3",abs:1,set:2,duration:1500,spacing:500,cnt:15};
  43. };
  44.  
  45. /**************************
  46. Special Events Script
  47. **************************/
  48. (function() {
  49. window.addEventListener('load', function(){
  50.  
  51. Game['eventSounds'] = [
  52. "https://ecdldaiiere.github.io/Eddiez-Soundz/PPT_tspinsingle.wav",
  53. "https://mattmayuga.github.io/Custom-jstris-sounds/PPT_tspinmini.wav",
  54. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99_clear1.wav",
  55. "https://mattmayuga.github.io/Custom-jstris-sounds/PPT_tspindouble.wav",
  56. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99_clear2.wav",
  57. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99_clear3.wav",
  58. "https://mattmayuga.github.io/Custom-jstris-sounds/PPT_tspintriple.wav",
  59. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99_clear4.wav",
  60. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99_perfectclear.wav",
  61. "https://mattmayuga.github.io/Custom-jstris-sounds/PPT_tspindouble.wav",
  62. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99_clear4.wav"
  63. ];
  64.  
  65. Game['eventVolumes'] = [1,1,1,1,1,1,1,1,1,1,1]
  66.  
  67.  
  68. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","PERFECT_CLEAR"]
  69. window.enableB2B = true;
  70.  
  71.  
  72. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  73. 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)}})
  74.  
  75.  
  76. var evVol = document.createElement("tr");
  77. 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>`
  78. tab_sound.appendChild(evVol);
  79.  
  80. if(typeof playSound != 'function') {
  81. 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())}
  82. }
  83.  
  84.  
  85. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","PERFECT_CLEAR"]
  86.  
  87. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  88. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  89.  
  90.  
  91. var clcFunc = Game['prototype']['checkLineClears'].toString()
  92. var clcParams = getParams(clcFunc)
  93. searchFor = "[_" + clcFunc.split("switch")[1].split("]][_")[2]
  94.  
  95. events.map((x,i)=>{
  96. replacement = searchFor.replace("[","[Game['btb']=this['isBack2Back'],Game['latestEv']='"+x+"',")
  97. clcFunc=clcFunc.replace(searchFor,replacement)
  98. })
  99.  
  100. Game['prototype']["checkLineClears"] = new Function(...clcParams, trim(clcFunc));
  101.  
  102. var psFunc = Game['prototype']['playSound'].toString()
  103. var psParams = getParams(psFunc);
  104. 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)
  105. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  106.  
  107. localStorage.mainVol = localStorage.mainVol || "100"
  108. document.getElementById("settingsSave").addEventListener("click", function(){
  109. localStorage.mainVol=document.getElementById('vol-control').value
  110. }, false);
  111.  
  112. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  113.  
  114.  
  115. /**************************
  116. Songs Script
  117. **************************/
  118.  
  119. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  120. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  121.  
  122.  
  123. localStorage.musicVol = localStorage.musicVol || "100";
  124. localStorage.SPvol = localStorage.SPvol || "100";
  125.  
  126. var musicVol = document.createElement("tr");
  127. 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>'
  128. tab_sound.appendChild(musicVol);
  129.  
  130. var spVol = document.createElement("tr");
  131. 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>'
  132. tab_sound.appendChild(spVol);
  133.  
  134.  
  135.  
  136. Game["setVol"] = function(vol,mode) {
  137. if(mode){
  138. localStorage.musicVol = vol
  139. volSetting.innerHTML=vol+'%';
  140. var musicVol=document.getElementById("volControl")
  141. Game["songs"].map(x=>{
  142. x.volume = (musicVol.value/100);
  143. })
  144. } else {
  145. localStorage.SPvol = vol
  146. volSetting2.innerHTML=vol+'%';
  147. var spVol=document.getElementById("volControl2")
  148. Game["song"].volume = spVol.value/100
  149. }
  150. }
  151.  
  152.  
  153. if(typeof Game != "undefined"){
  154.  
  155.  
  156. var songsMP = [
  157. "https://ecdldaiiere.github.io/Eddiez-Soundz/TFsong1.mp3",
  158. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99song2.mp3",
  159. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99song3.mp3"
  160. ]
  161.  
  162. var songSP = "https://ecdldaiiere.github.io/Eddiez-Soundz/TFsong1.mp3"
  163.  
  164. //Play song when only X*100% of players are left (first one is always 1)
  165. var songThresholds = [1, 0.6, 0.2]
  166.  
  167. Game['onlySprint'] = false;
  168.  
  169.  
  170. window.playSong = function(s) {
  171. Game["songs"].map(x=>{
  172. x.pause();
  173. x.currentTime = 0;
  174. })
  175. Game["song"].pause();
  176. Game["song"].currentTime = 0;
  177.  
  178. if(s != undefined){
  179. !s.paused&&0<s.currentTime?s.currentTime=0:s.play()
  180. }
  181. }
  182.  
  183. Game["songs"] = [];
  184. Game["maxPlayers"] = 0
  185. Game["songIndex"] = -1
  186.  
  187.  
  188. Game["song"] = document.createElement("audio");
  189. Game["song"].src = songSP;
  190. Game["song"].loop = true;
  191. Game["song"].volume = 1;
  192.  
  193. songsMP.map((x,i)=>{
  194. Game["songs"].push(document.createElement("audio"));
  195. Game["songs"][i].src = x;
  196. Game["songs"][i].loop = true;
  197. Game["songs"][i].volume = 1;
  198. })
  199.  
  200. Game["setVol"](localStorage.musicVol,1)
  201. Game["setVol"](localStorage.SPvol,0)
  202.  
  203.  
  204. Game["updateSong"] = function(i) {
  205.  
  206. if(i<0){
  207. Game["maxPlayers"] = 0
  208. playSong()
  209. Game["songIndex"] = -1
  210. }
  211.  
  212. if(i==0){
  213. Game["maxPlayers"]= -1
  214. playSong(Game["songs"][0])
  215. Game["songIndex"] = 0
  216. }
  217.  
  218. if(typeof i == "string"){
  219. if(Game["maxPlayers"]<0){
  220. Game["maxPlayers"]=parseInt(i)
  221. }
  222. var alivePercent = (parseInt(i)-1)/Game["maxPlayers"]
  223. if(alivePercent <= songThresholds[Game["songIndex"]+1]){
  224. console.log(Game["songIndex"])
  225. Game["songIndex"]++
  226. playSong(Game["songs"][Game["songIndex"]])
  227. }
  228. }
  229.  
  230. }
  231.  
  232. var gameOver99 = Game['prototype']['GameOver'].toString();
  233. gameOver99 = "Game['updateSong'](-1);Game['song'].pause();Game['song'].currentTime=0;" + trim(gameOver99)
  234. Game['prototype']['GameOver'] = new Function(gameOver99)
  235.  
  236. var printSlot99 = SlotView['prototype']['printSlotPlace'].toString()
  237. var printSlotParams = getParams(printSlot99);
  238. printSlot99 = `Game["updateSong"](this['slot']['gs']['p']['getPlaceColor'](${printSlotParams[0]})['str']);` + trim(printSlot99)
  239. SlotView['prototype']['printSlotPlace'] = new Function(...printSlotParams, printSlot99);
  240.  
  241.  
  242.  
  243. var readyGo99 = Game['prototype']['restart'].toString()
  244. 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)
  245. Game['prototype']['restart'] = new Function(readyGo99);
  246.  
  247. var specMode99 = Live['prototype']['spectatorMode'].toString()
  248. var specParams = getParams(specMode99);
  249. specMode99 = `Game['updateSong'](-1);` + trim(specMode99)
  250. Live['prototype']['spectatorMode'] = new Function(...specParams, specMode99);
  251.  
  252. var paint99 = Game['prototype']['paintMatrixWithColor'].toString()
  253. var paintParams = getParams(paint99);
  254. paint99 = `Game['updateSong'](-1);` + trim(paint99)
  255. Game['prototype']['paintMatrixWithColor'] = new Function(...paintParams, paint99);
  256.  
  257.  
  258.  
  259. //remove these 3 lines if you dont want the music to stop for the countdown
  260. var readyGo992 = Game['prototype']['readyGo'].toString()
  261. readyGo992 = "Game['updateSong'](-1);" + trim(readyGo992)
  262. Game['prototype']['readyGo'] = new Function(readyGo992);
  263. }
  264. if(typeof Game != "undefined"){
  265. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  266.  
  267. document['addEventListener']('keydown', press);
  268. document['addEventListener']('keyup', press);
  269.  
  270. function press(e) {
  271. if(~Game['set2ings'].indexOf(e.keyCode)){
  272. var corresponding = [6,8,1,2,3,5,4,0][Game['set2ings'].indexOf(e.keyCode)]
  273. document.getElementsByClassName("kbkey")[corresponding].style.backgroundColor = ["lightgoldenrodyellow",""][+(e.type=="keyup")]
  274. }
  275. }
  276.  
  277. var kbhold=document.createElement("div");
  278. kbhold.id="keyboardHolder";
  279. kbhold.style.position="absolute"
  280. kbhold.style.left = (myCanvas.getBoundingClientRect().left - 300) + "px";
  281. kbhold.style.top = (myCanvas.getBoundingClientRect().top + 100) + "px";
  282. document.body.appendChild(kbhold);
  283.  
  284. var f='<R>M{text-align:center;position: absolute;font-size:15px`{]-Q:QIspacing:0;Nred`td|th|Uwp8o_000000;]:inherit`UT_34ff34`Ujy2k_f8a102`UO_f8ff00;}</RYbo"Yps"KPJV"Ptr^Tq180~TqSD~TqHDZ[CCWZXtr^OqHL~OqCWZ[&lt;[v[&gt;X/JK>~</td^|{padding:10px 5pxIR:solidIwidth:2px`q kbkey">`;}M.tg _{]-N#^PtdV-]border[~jy2kqZ~wp8o">YPdiv id="kX</tdP/trPV class="tgU.tg-Ttc3eRstyleQcollapseP><Op39mNcolor:M#kbo KP/divJtableI;]-';var g=0;var i=0;for(i in g='IJKMNOPQRTUVXYZ[]^_`q|~')var e=f.split(g[i]),f=e.join(e.pop())
  285. keyboardHolder.innerHTML = f
  286.  
  287. var set2ings = Game['prototype']['readyGo'].toString()
  288. set2ings = "Game['set2ings']=this.Settings.controls;" + trim(set2ings)
  289. Game['prototype']['readyGo'] = new Function(set2ings);
  290.  
  291. var updateTextBarFunc = Game['prototype']['updateTextBar'].toString()
  292. updateTextBarFunc = trim(updateTextBarFunc) + ";kps.innerHTML='KPS: '+(this.getKPP()*this.placedBlocks/this.clock).toFixed(2)"
  293. Game['prototype']['updateTextBar'] = new Function(updateTextBarFunc);
  294.  
  295. }
  296.  
  297. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  298. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  299. if(typeof Game != "undefined"){
  300.  
  301. var aliveHold=document.createElement("div");
  302. aliveHold.id="aliveHolder";
  303. aliveHold.style.position="absolute"
  304. aliveHold.style.left = (myCanvas.getBoundingClientRect().left - 200) + "px";
  305. aliveHold.style.top = (myCanvas.getBoundingClientRect().top + 400) + "px";
  306. document.body.appendChild(aliveHold);
  307.  
  308. var f='<div id="lrem"><div id="aliveNum"></div></div><div id="sprintText"><div id="stLrem" style="display: block;">opponents remaining</div></div>'
  309. aliveHolder.innerHTML = f
  310. aliveHolder.style.display='none'
  311.  
  312. var printAlive = SlotView['prototype']['printSlotPlace'].toString()
  313. var printAliveParams = getParams(printAlive);
  314. printAlive = `aliveHolder.style.display='block';aliveNum.innerHTML=parseInt(this['slot']['gs']['p']['getPlaceColor'](${printAliveParams[0]})['str'])-1;` + trim(printAlive)
  315. SlotView['prototype']['printSlotPlace'] = new Function(...printAliveParams, printAlive);
  316.  
  317. var readyGoAlive = Game['prototype']['restart'].toString()
  318. readyGoAlive = "if(this['pmode']+this['isPmode'](true)+this['isPmode'](false)==0){aliveHolder.style.display='block';aliveNum.innerHTML='all'};" + trim(readyGoAlive)
  319. Game['prototype']['restart'] = new Function(readyGoAlive);
  320.  
  321. }
  322.  
  323. });
  324. })();