The Ultimate Jstris Script

Multiple script code in one script

目前为 2020-10-19 提交的版本,查看 最新版本

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