The Ultimate Jstris Script alter-ver. 1

Multiple script code in one script

当前为 2020-09-18 提交的版本,查看 最新版本

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