The Ultimate Jstris Script alter-ver. 1

Multiple script code in one script

当前为 2019-07-18 提交的版本,查看 最新版本

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