The Ultimate Jstris Script alter-ver. 1

Multiple script code in one script

  1. // ==UserScript==
  2. // @name The Ultimate Jstris Script alter-ver. 1
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.34
  5. // @description Multiple script code in one script
  6. // @author julf, MattMayuga, Oki, Eddie
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. window.addEventListener('load', function(){
  17. //Jstris Custom Background Image
  18. document.head.getElementsByTagName("style")[0].innerHTML="";
  19. document.body.style.backgroundImage="url('https://i.imgur.com/jkg9VE5.png')";
  20. document.body.style.backgroundSize="100%";
  21. document.getElementById("app").style.backgroundColor="rgba(0, 0, 0, 0.7)";
  22. document.getElementById("app").style.height="1000px";
  23.  
  24. //Jstris Block Skin Change
  25. loadSkin("https://i.imgur.com/T7PyM45.png",32);
  26. loadGhostSkin("https://i.imgur.com/VbOkRzd.png",36);
  27.  
  28. //Jstris SFX
  29. CustomSFXset.prototype = new BaseSFXset;
  30. loadSFX(new CustomSFXset);
  31.  
  32. });
  33. })();
  34.  
  35. function CustomSFXset(){
  36. this.volume=1;
  37. this.lock={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Han_lock.mp3",abs:1};
  38. this.ready={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Han_ready.mp3",abs:1,set:1};
  39. this.go={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Han_go.mp3",abs:1,set:0};
  40. this.died={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Han_died.wav",abs:1,set:1};
  41. this.hold={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Han_hold.mp3",abs:1,set:0};
  42. this.move={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Han_move.wav",abs:1,set:0};
  43. this.comboTones={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Hancombo.mp3",abs:1,set:2,duration:1500,spacing:500,cnt:15};
  44. };
  45.  
  46. /**************************
  47. Opponent's Field Grid Script
  48. **************************/
  49.  
  50. var customStyle=document.createElement("style");
  51. customStyle.innerHTML='.players .bgLayer{display:none;}';
  52. document.body.appendChild(customStyle);
  53.  
  54. /**************************
  55. Special Events Script
  56. **************************/
  57. (function() {
  58. window.addEventListener('load', function(){
  59.  
  60. Game['eventSounds'] = [
  61. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_tspinsingle.mp3",
  62. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_tspinmini.mp3",
  63. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_clear1.mp3",
  64. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_tspindouble.mp3",
  65. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_clear2.mp3",
  66. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_clear3.mp3",
  67. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_tspintriple.mp3",
  68. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_clear4.mp3",
  69. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_clear5.mp3",
  70. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_perfectclear.mp3",
  71. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_b2btspin.mp3",
  72. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_b2btetris.mp3"
  73. ];
  74.  
  75. Game['eventVolumes'] = [1,1,1,1,1,1,1,1,1,1,1,1]
  76.  
  77.  
  78. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  79. window.enableB2B = true;
  80.  
  81.  
  82. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  83. 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)}})
  84.  
  85.  
  86. var evVol = document.createElement("tr");
  87. 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>`
  88. tab_sound.appendChild(evVol);
  89.  
  90. if(typeof playSound != 'function') {
  91. 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())}
  92. }
  93.  
  94.  
  95. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  96.  
  97. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  98. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  99.  
  100.  
  101. var clcFunc = Game['prototype']['checkLineClears'].toString()
  102. var clcParams = getParams(clcFunc)
  103. searchFor = "[_" + clcFunc.split("switch")[1].split("]][_")[2]
  104.  
  105. events.map((x,i)=>{
  106. replacement = searchFor.replace("[","[Game['btb']=this['isBack2Back'],console.log('"+x+"'),Game['latestEv']='"+x+"',")
  107. clcFunc=clcFunc.replace(searchFor,replacement)
  108. })
  109.  
  110. Game['prototype']["checkLineClears"] = new Function(...clcParams, trim(clcFunc));
  111.  
  112. var psFunc = Game['prototype']['playSound'].toString()
  113. var psParams = getParams(psFunc);
  114. psFunc = `
  115. if(Game["latestEv"]){
  116. sIndex=events.indexOf(Game["latestEv"]);
  117. console.log(sIndex)
  118. sound=sIndex;enableB2B&&Game.btb&&~[0,1,3,5,7,8].indexOf(sIndex)&&(sound=10+ +(7==sIndex));
  119. console.log(sound);
  120. Game.sArray[sound]&&playSound(sound);
  121. Game["latestEv"]="";
  122. }` + trim(psFunc)
  123.  
  124. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  125.  
  126. localStorage.mainVol = localStorage.mainVol || "100"
  127. document.getElementById("settingsSave").addEventListener("click", function(){
  128. localStorage.mainVol=document.getElementById('vol-control').value
  129. }, false);
  130.  
  131. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  132.  
  133. /**************************
  134. Rotation Sounds Script
  135. **************************/
  136.  
  137. Game['rotationSounds'] = [
  138. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_rotate.mp3", //rotate left
  139. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_rotate.mp3", //rotate right
  140. "https://ecdldaiiere.github.io/Eddiez-Soundz/Han_rotate.mp3" //rotate 180°
  141. ];
  142.  
  143. Game['rotationVolumes'] = [1,1,1]
  144.  
  145. localStorage.evVol=localStorage.evVol||"100"
  146.  
  147. Game["rArray"]=[];
  148. 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)}})
  149.  
  150.  
  151. 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())}
  152.  
  153.  
  154. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  155. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  156.  
  157. var rotFunc = Game['prototype']['rotateCurrentBlock'].toString()
  158. var rotParams = getParams(rotFunc)
  159.  
  160. var rotInsert = 'var rotPos=[0,0,1,2]['+rotParams[0]+'+1];console.log(rotPos);Game.rArray[rotPos]&&playRotSound(rotPos);'
  161.  
  162. rotFunc = rotInsert + trim(rotFunc)
  163.  
  164. Game['prototype']['rotateCurrentBlock'] = new Function(...rotParams, rotFunc);
  165.  
  166. /**************************
  167. Songs Script
  168. **************************/
  169.  
  170. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  171. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  172.  
  173.  
  174. localStorage.musicVol = localStorage.musicVol || "100";
  175. localStorage.SPvol = localStorage.SPvol || "100";
  176.  
  177. var musicVol = document.createElement("tr");
  178. 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>'
  179. tab_sound.appendChild(musicVol);
  180.  
  181. var spVol = document.createElement("tr");
  182. 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>'
  183. tab_sound.appendChild(spVol);
  184.  
  185.  
  186.  
  187. Game["setVol"] = function(vol,mode) {
  188. if(mode){
  189. localStorage.musicVol = vol
  190. volSetting.innerHTML=vol+'%';
  191. var musicVol=document.getElementById("volControl")
  192. Game["songs"].map(x=>{
  193. x.volume = (musicVol.value/100);
  194. })
  195. } else {
  196. localStorage.SPvol = vol
  197. volSetting2.innerHTML=vol+'%';
  198. var spVol=document.getElementById("volControl2")
  199. Game["song"].volume = spVol.value/100
  200. }
  201. }
  202.  
  203.  
  204. if(typeof Game != "undefined"){
  205.  
  206.  
  207. var songsMP = [
  208. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99song1.mp3",
  209. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99song2.mp3",
  210. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99song3.mp3"
  211. ]
  212.  
  213. var songSP = "https://ecdldaiiere.github.io/Eddiez-Soundz/t99song1.mp3"
  214.  
  215. var songThresholds = [1, 0.6, 0.2]
  216.  
  217. Game['onlySprint'] = false;
  218.  
  219.  
  220. window.playSong = function(s) {
  221. Game["songs"].map(x=>{
  222. x.pause();
  223. x.currentTime = 0;
  224. })
  225. Game["song"].pause();
  226. Game["song"].currentTime = 0;
  227.  
  228. if(s != undefined){
  229. !s.paused&&0<s.currentTime?s.currentTime=0:s.play()
  230. }
  231. }
  232.  
  233. Game["songs"] = [];
  234. Game["maxPlayers"] = 0
  235. Game["songIndex"] = -1
  236.  
  237.  
  238. Game["song"] = document.createElement("audio");
  239. Game["song"].src = songSP;
  240. Game["song"].loop = true;
  241. Game["song"].volume = 1;
  242.  
  243. songsMP.map((x,i)=>{
  244. Game["songs"].push(document.createElement("audio"));
  245. Game["songs"][i].src = x;
  246. Game["songs"][i].loop = true;
  247. Game["songs"][i].volume = 1;
  248. })
  249.  
  250. Game["setVol"](localStorage.musicVol,1)
  251. Game["setVol"](localStorage.SPvol,0)
  252.  
  253.  
  254. Game["updateSong"] = function(i) {
  255.  
  256. if(i<0){
  257. Game["maxPlayers"] = 0
  258. playSong()
  259. Game["songIndex"] = -1
  260. }
  261.  
  262. if(i==0){
  263. Game["maxPlayers"]= -1
  264. playSong(Game["songs"][0])
  265. Game["songIndex"] = 0
  266. }
  267.  
  268. if(typeof i == "string"){
  269. if(Game["maxPlayers"]<0){
  270. Game["maxPlayers"]=parseInt(i)
  271. }
  272. var alivePercent = (parseInt(i)-1)/Game["maxPlayers"]
  273. if(alivePercent <= songThresholds[Game["songIndex"]+1]){
  274. console.log(Game["songIndex"])
  275. Game["songIndex"]++
  276. playSong(Game["songs"][Game["songIndex"]])
  277. }
  278. }
  279.  
  280. }
  281.  
  282. var gameOver99 = Game['prototype']['GameOver'].toString();
  283. gameOver99 = "Game['updateSong'](-1);Game['song'].pause();Game['song'].currentTime=0;" + trim(gameOver99)
  284. Game['prototype']['GameOver'] = new Function(gameOver99)
  285.  
  286. var printSlot99 = SlotView['prototype']['printSlotPlace'].toString()
  287. var printSlotParams = getParams(printSlot99);
  288. printSlot99 = `Game["updateSong"](this['slot']['gs']['p']['getPlaceColor'](${printSlotParams[0]})['str']);` + trim(printSlot99)
  289. SlotView['prototype']['printSlotPlace'] = new Function(...printSlotParams, printSlot99);
  290.  
  291.  
  292.  
  293. var readyGo99 = Game['prototype']['restart'].toString()
  294. 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)
  295. Game['prototype']['restart'] = new Function(readyGo99);
  296.  
  297. var specMode99 = Live['prototype']['spectatorMode'].toString()
  298. var specParams = getParams(specMode99);
  299. specMode99 = `Game['updateSong'](-1);` + trim(specMode99)
  300. Live['prototype']['spectatorMode'] = new Function(...specParams, specMode99);
  301.  
  302. var paint99 = Game['prototype']['paintMatrixWithColor'].toString()
  303. var paintParams = getParams(paint99);
  304. paint99 = `Game['updateSong'](-1);` + trim(paint99)
  305. Game['prototype']['paintMatrixWithColor'] = new Function(...paintParams, paint99);
  306.  
  307.  
  308. //remove these 3 lines if you dont want the music to stop for the countdown
  309. var readyGo992 = Game['prototype']['readyGo'].toString()
  310. readyGo992 = "Game['updateSong'](-1);" + trim(readyGo992)
  311. Game['prototype']['readyGo'] = new Function(readyGo992);
  312. }
  313.  
  314. /**************************
  315. Keyboard Display Script
  316. **************************/
  317.  
  318. if(typeof Game != "undefined"){
  319. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  320.  
  321. document['addEventListener']('keydown', press);
  322. document['addEventListener']('keyup', press);
  323.  
  324. function press(e) {
  325. if(~Game['set2ings'].indexOf(e.keyCode)){
  326. var corresponding = [6,8,1,2,3,5,4,0][Game['set2ings'].indexOf(e.keyCode)]
  327. document.getElementsByClassName("kbkey")[corresponding].style.backgroundColor = ["lightgoldenrodyellow",""][+(e.type=="keyup")]
  328. }
  329. }
  330.  
  331. var kbhold=document.createElement("div");
  332. kbhold.id="keyboardHolder";
  333. kbhold.style.position="absolute"
  334. kbhold.style.left = (myCanvas.getBoundingClientRect().left - 300) + "px";
  335. kbhold.style.top = (myCanvas.getBoundingClientRect().top + 100) + "px";
  336. document.body.appendChild(kbhold);
  337.  
  338. 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())
  339. keyboardHolder.innerHTML = f
  340.  
  341. var set2ings = Game['prototype']['readyGo'].toString()
  342. set2ings = "Game['set2ings']=this.Settings.controls;" + trim(set2ings)
  343. Game['prototype']['readyGo'] = new Function(set2ings);
  344.  
  345. var updateTextBarFunc = Game['prototype']['updateTextBar'].toString()
  346. updateTextBarFunc = trim(updateTextBarFunc) + ";kps.innerHTML='KPS: '+(this.getKPP()*this.placedBlocks/this.clock).toFixed(2)"
  347. Game['prototype']['updateTextBar'] = new Function(updateTextBarFunc);
  348.  
  349. }
  350.  
  351. /**************************
  352. Opponents Left Script
  353. **************************/
  354.  
  355. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  356. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  357. if(typeof Game != "undefined"){
  358.  
  359. var aliveHold=document.createElement("div");
  360. aliveHold.id="aliveHolder";
  361. aliveHold.style.position="absolute"
  362. aliveHold.style.left = (myCanvas.getBoundingClientRect().left - 200) + "px";
  363. aliveHold.style.top = (myCanvas.getBoundingClientRect().top + 400) + "px";
  364. document.body.appendChild(aliveHold);
  365.  
  366. var f='<div id="lrem"><div id="aliveNum"></div></div><div id="sprintText"><div id="stLrem" style="display: block;">opponents remaining</div></div>'
  367. aliveHolder.innerHTML = f
  368. aliveHolder.style.display='none'
  369.  
  370. var printAlive = SlotView['prototype']['printSlotPlace'].toString()
  371. var printAliveParams = getParams(printAlive);
  372. printAlive = `aliveHolder.style.display='block';aliveNum.innerHTML=parseInt(this['slot']['gs']['p']['getPlaceColor'](${printAliveParams[0]})['str'])-1;` + trim(printAlive)
  373. SlotView['prototype']['printSlotPlace'] = new Function(...printAliveParams, printAlive);
  374.  
  375. var readyGoAlive = Game['prototype']['restart'].toString()
  376. readyGoAlive = "if(this['pmode']+this['isPmode'](true)+this['isPmode'](false)==0){aliveHolder.style.display='block';aliveNum.innerHTML='all'};" + trim(readyGoAlive)
  377. Game['prototype']['restart'] = new Function(readyGoAlive);
  378.  
  379. }
  380.  
  381. /**************************
  382. Chat Timestamp Script
  383. **************************/
  384.  
  385. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  386. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  387.  
  388. var insertChat = ';var s=document.createElement("span");s.style="color:gray";s.innerHTML = "["+new Date().toTimeString().slice(0,8)+"] ";var c=document.getElementsByClassName("chl");c[c.length-1].prepend(s);'
  389.  
  390. var sicFunc = Live['prototype']['showInChat'].toString()
  391. var paramsChat = getParams(sicFunc)
  392.  
  393. sicFunc = trim(sicFunc) + insertChat
  394.  
  395. Live['prototype']["showInChat"] = new Function(...paramsChat, sicFunc);
  396.  
  397. });
  398. })();