Splatoon Theme

Splatoon Theme for Jstris

  1. // ==UserScript==
  2. // @name Splatoon Theme
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.77
  5. // @description Splatoon Theme for Jstris
  6. // @author 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.  
  17. //Jstris Block Skin Change
  18. loadSkin("https://i.imgur.com/PtW72rR.png",48);
  19. loadGhostSkin("https://i.imgur.com/j7VRYsc.png",48);
  20.  
  21. //Jstris Custom Background Image
  22. document.head.getElementsByTagName("style")[0].innerHTML="";
  23. document.body.style.backgroundImage="url('https://i.imgur.com/CRFHx5l.png')";
  24. document.body.style.backgroundSize="100% 100%";
  25. document.getElementById("app").style.backgroundColor="rgba(0, 0, 0, 0)";
  26. document.getElementById("app").style.height="1000px";
  27. bgLayer.style.opacity=0.95 //grid opacity change
  28.  
  29. //Jstris SFX
  30. CustomSFXset.prototype = new BaseSFXset;
  31. loadSFX(new CustomSFXset);
  32.  
  33. });
  34. })();
  35.  
  36. function CustomSFXset(){
  37. this.volume=1;
  38. this.lock={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_lock.wav",abs:1};
  39. this.ready={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Splat_ready.mp3",abs:1,set:1};
  40. this.go={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_go.wav",abs:1,set:0};
  41. this.died={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_died.wav",abs:1,set:1};
  42. this.hold={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Splat_hold.mp3",abs:1,set:0};
  43. this.move={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_move.wav",abs:1,set:0};
  44. this.linefall={url:"blank.wav",abs:1,set:0};
  45. };
  46.  
  47. /************************************
  48. T99 Grid Script
  49. ************************************/
  50. (function() {
  51. window.addEventListener('load', function(){
  52.  
  53. customFieldBorder = true //change to false to disable
  54.  
  55. if(customFieldBorder){
  56. if(typeof Game != "undefined"){
  57.  
  58. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  59. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  60.  
  61. function atGameStart() {
  62.  
  63. bgLayer.width = 500
  64. bgLayer.height = 650
  65. bgLayer.style.left = "-"+((880-248)/2)/2+"px"
  66. bgLayer.style.top = "-"+((1080-480)/2)/2+"px"
  67. this.drawBgGrid(1);
  68. var bgctx = bgLayer.getContext("2d");
  69. var img = new Image;
  70. img.onload = function(){
  71. bgctx.clearRect(0, 0, 880, 1080);
  72. bgctx.drawImage(img,58,120,880/2,1080/2); // Or at whatever offset you like
  73. };
  74. img.src = "https://i.imgur.com/8eAsRnk.png";
  75. sprintInfo.style.zIndex = "100000";
  76. }
  77.  
  78. var initRandom = GameCore['prototype']['initRandomizer'].toString()
  79. var initRandomParams = getParams(initRandom)
  80. initRandom = trim(atGameStart.toString()) + trim(initRandom)
  81. GameCore['prototype']['initRandomizer'] = new Function(...initRandomParams, initRandom);
  82.  
  83.  
  84.  
  85.  
  86. var queueC = queueCanvas.getBoundingClientRect();
  87.  
  88. for (var i = 0; i < 5; i++) {
  89. var qCC = document.createElement("canvas");
  90. qCC.id = "queueCopy" + i
  91. qCC.className = "queueCopy"
  92. qCC.style.position = "absolute";
  93. qCC.style.left = queueC.left+"px";
  94. qCC.style.top = queueC.top+(72*i)+"px";
  95. qCC.height=72
  96. i&&(qCC.style.transform = "translatey("+(72*i)+") ")
  97. qCC.width=queueCanvas.width
  98. document.body.appendChild(qCC)
  99.  
  100. }
  101.  
  102. var customStyleQueue=document.createElement("style");
  103. customStyleQueue.innerHTML='#queueCanvas {visibility:hidden;} .queueCopy {z-index:1} #holdCanvas {z-index:2}';
  104. document.body.appendChild(customStyleQueue);
  105.  
  106.  
  107. var updateQueueBoxFunc = Game['prototype']['updateQueueBox'].toString()
  108.  
  109. var inject = `;for (var i = 0; i < 5; i++) {
  110. var destCanvas = document.getElementById("queueCopy"+i)
  111. var destCtx = destCanvas.getContext('2d');
  112. destCtx.clearRect(0, 0, destCanvas.width, destCanvas.height);
  113. destCtx.drawImage(queueCanvas, 0, -i*72);}`
  114.  
  115. updateQueueBoxFunc = trim(updateQueueBoxFunc) + inject
  116.  
  117. Game['prototype']["updateQueueBox"] = new Function(updateQueueBoxFunc);
  118.  
  119. queueCopies = [queueCopy0,queueCopy1,queueCopy2,queueCopy3,queueCopy4]
  120.  
  121. i=0
  122. queueCopies.map(x=>{
  123. x.style.transform += "scale(0.5,0.5)"
  124. x.style.transform += "translate(-75px,"+ -i*40 +"px)"
  125. i++
  126. })
  127.  
  128. holdCanvas.style.float = "none"
  129. holdCanvas.style.position = "absolute"
  130. holdCanvas.style.transform = "scale(0.5,0.5)"
  131. holdCanvas.style.top = "2px"
  132. holdCanvas.style.left = "28px"
  133.  
  134.  
  135. rInfoBox.style.position = "absolute"
  136. rInfoBox.style.zIndex = 100
  137. rInfoBox.style.marginLeft = "90px"
  138. rInfoBox.style.transform = "scale(0.8,0.8)"
  139.  
  140. stage.style.left = "112px"}
  141.  
  142. }
  143.  
  144. });
  145. })();
  146.  
  147. /**************************
  148. Opponent's Color Script
  149. **************************/
  150.  
  151. var customStyle2=document.createElement("style");
  152. customStyle2.innerHTML='.slot span a {color:rgba(113, 74, 219, 100);} .slot span {color:rgba(206, 246, 36, 100);}';
  153. document.body.appendChild(customStyle2);
  154.  
  155. /**************************
  156. Opponent's Field Grid Script
  157. **************************/
  158.  
  159. var customStyle=document.createElement("style");
  160. customStyle.innerHTML='.players .bgLayer{display:none;}';
  161. document.body.appendChild(customStyle);
  162.  
  163. /**************************
  164. Remaining Players Script
  165. **************************/
  166.  
  167. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  168. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  169. if(typeof Game != "undefined"){
  170.  
  171. var aliveHold=document.createElement("div");
  172. aliveHold.id="aliveHolder";
  173. aliveHold.style.position="absolute"
  174. aliveHold.style.left = (myCanvas.getBoundingClientRect().left - 200) + "px";
  175. aliveHold.style.top = (myCanvas.getBoundingClientRect().top + 400) + "px";
  176. document.body.appendChild(aliveHold);
  177.  
  178. var f='<div id="lrem"><div id="aliveNum"></div></div><div id="sprintText"><div id="stLrem" style="display: block;">opponents remaining</div></div>'
  179. aliveHolder.innerHTML = f
  180. aliveHolder.style.display='none'
  181.  
  182. var printAlive = SlotView['prototype']['printSlotPlace'].toString()
  183. var printAliveParams = getParams(printAlive);
  184. printAlive = `aliveHolder.style.display='block';aliveNum.innerHTML=parseInt(this['slot']['gs']['p']['getPlaceColor'](${printAliveParams[0]})['str'])-1;` + trim(printAlive)
  185. SlotView['prototype']['printSlotPlace'] = new Function(...printAliveParams, printAlive);
  186.  
  187. var readyGoAlive = Game['prototype']['restart'].toString()
  188. readyGoAlive = "if(this['pmode']+this['isPmode'](true)+this['isPmode'](false)==0){aliveHolder.style.display='block';aliveNum.innerHTML='all'};" + trim(readyGoAlive)
  189. Game['prototype']['restart'] = new Function(readyGoAlive);
  190. }
  191.  
  192. /**************************
  193. Special Events Script
  194. **************************/
  195. (function() {
  196. window.addEventListener('load', function(){
  197.  
  198. Game['eventSounds'] = [
  199. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_clear1.wav",
  200. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_clear1.wav",
  201. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_clear1.wav",
  202. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_clear2.wav",
  203. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_clear2.wav",
  204. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_clear3.wav",
  205. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_clear3.wav",
  206. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_clear4.wav",
  207. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_clear5.mp3",
  208. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99_perfectclear.wav",
  209. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_b2btspin.mp3",
  210. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_b2btetris.mp3"
  211. ];
  212.  
  213. Game['eventVolumes'] = [1,1,1,1,1,1,1,1,1,1,1,1]
  214.  
  215.  
  216. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  217. window.enableB2B = true;
  218.  
  219.  
  220. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  221. 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)}})
  222.  
  223.  
  224. var evVol = document.createElement("tr");
  225. 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>`
  226. tab_sound.appendChild(evVol);
  227.  
  228. if(typeof playSound != 'function') {
  229. 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())}
  230. }
  231.  
  232.  
  233. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  234.  
  235. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  236. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  237.  
  238.  
  239. var clcFunc = Game['prototype']['checkLineClears'].toString()
  240. var clcParams = getParams(clcFunc)
  241. searchFor = "[_" + clcFunc.split("switch")[1].split("]][_")[2]
  242.  
  243. events.map((x,i)=>{
  244. replacement = searchFor.replace("[","[Game['btb']=this['isBack2Back'],console.log('"+x+"'),Game['latestEv']='"+x+"',")
  245. clcFunc=clcFunc.replace(searchFor,replacement)
  246. })
  247.  
  248. Game['prototype']["checkLineClears"] = new Function(...clcParams, trim(clcFunc));
  249.  
  250. var psFunc = Game['prototype']['playSound'].toString()
  251. var psParams = getParams(psFunc);
  252. psFunc = `
  253. if(Game["latestEv"]){
  254. sIndex=events.indexOf(Game["latestEv"]);
  255. console.log(sIndex)
  256. sound=sIndex;enableB2B&&Game.btb&&~[0,1,3,5,7,8].indexOf(sIndex)&&(sound=10+ +(7==sIndex));
  257. console.log(sound);
  258. Game.sArray[sound]&&playSound(sound);
  259. Game["latestEv"]="";
  260. }` + trim(psFunc)
  261.  
  262. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  263.  
  264. localStorage.mainVol = localStorage.mainVol || "100"
  265. document.getElementById("settingsSave").addEventListener("click", function(){
  266. localStorage.mainVol=document.getElementById('vol-control').value
  267. }, false);
  268.  
  269. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  270.  
  271. /**************************
  272. Rotation Sounds Script
  273. **************************/
  274.  
  275. Game['rotationSounds'] = [
  276. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_rotate.wav", //rotate left
  277. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_rotate.wav", //rotate right
  278. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatoon_rotate.wav" //rotate 180°
  279. ];
  280.  
  281. Game['rotationVolumes'] = [1,1,1]
  282.  
  283. localStorage.evVol=localStorage.evVol||"100"
  284.  
  285. Game["rArray"]=[];
  286. 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)}})
  287.  
  288.  
  289. 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())}
  290.  
  291.  
  292. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  293. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  294.  
  295. var rotFunc = Game['prototype']['rotateCurrentBlock'].toString()
  296. var rotParams = getParams(rotFunc)
  297.  
  298. var rotInsert = 'var rotPos=[0,0,1,2]['+rotParams[0]+'+1];console.log(rotPos);Game.rArray[rotPos]&&playRotSound(rotPos);'
  299.  
  300. rotFunc = rotInsert + trim(rotFunc)
  301.  
  302. Game['prototype']['rotateCurrentBlock'] = new Function(...rotParams, rotFunc);
  303.  
  304.  
  305. /**************************
  306. Songs Script
  307. **************************/
  308.  
  309. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  310. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  311.  
  312.  
  313. localStorage.musicVol = localStorage.musicVol || "100";
  314. localStorage.SPvol = localStorage.SPvol || "100";
  315.  
  316. var musicVol = document.createElement("tr");
  317. 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>'
  318. tab_sound.appendChild(musicVol);
  319.  
  320. var spVol = document.createElement("tr");
  321. 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>'
  322. tab_sound.appendChild(spVol);
  323.  
  324.  
  325.  
  326. Game["setVol"] = function(vol,mode) {
  327. if(mode){
  328. localStorage.musicVol = vol
  329. volSetting.innerHTML=vol+'%';
  330. var musicVol=document.getElementById("volControl")
  331. Game["songs"].map(x=>{
  332. x.volume = (musicVol.value/100);
  333. })
  334. } else {
  335. localStorage.SPvol = vol
  336. volSetting2.innerHTML=vol+'%';
  337. var spVol=document.getElementById("volControl2")
  338. Game["song"].volume = spVol.value/100
  339. }
  340. }
  341.  
  342.  
  343. if(typeof Game != "undefined"){
  344.  
  345.  
  346. var songsMP = [
  347. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatsong1.mp3",
  348. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatsong2.mp3",
  349. "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatsong3.mp3"
  350. ]
  351.  
  352. var songSP = "https://ecdldaiiere.github.io/Eddiez-Soundz/Splatsong1.mp3"
  353.  
  354. //Play song when only X*100% of players are left (first one is always 1)
  355. var songThresholds = [1, 0.6, 0.2]
  356.  
  357. Game['onlySprint'] = false;
  358.  
  359.  
  360. window.playSong = function(s) {
  361. Game["songs"].map(x=>{
  362. x.pause();
  363. x.currentTime = 0;
  364. })
  365. Game["song"].pause();
  366. Game["song"].currentTime = 0;
  367.  
  368. if(s != undefined){
  369. !s.paused&&0<s.currentTime?s.currentTime=0:s.play()
  370. }
  371. }
  372.  
  373. Game["songs"] = [];
  374. Game["maxPlayers"] = 0
  375. Game["songIndex"] = -1
  376.  
  377.  
  378. Game["song"] = document.createElement("audio");
  379. Game["song"].src = songSP;
  380. Game["song"].loop = true;
  381. Game["song"].volume = 1;
  382.  
  383. songsMP.map((x,i)=>{
  384. Game["songs"].push(document.createElement("audio"));
  385. Game["songs"][i].src = x;
  386. Game["songs"][i].loop = true;
  387. Game["songs"][i].volume = 1;
  388. })
  389.  
  390. Game["setVol"](localStorage.musicVol,1)
  391. Game["setVol"](localStorage.SPvol,0)
  392.  
  393.  
  394. Game["updateSong"] = function(i) {
  395.  
  396. if(i<0){
  397. Game["maxPlayers"] = 0
  398. playSong()
  399. Game["songIndex"] = -1
  400. }
  401.  
  402. if(i==0){
  403. Game["maxPlayers"]= -1
  404. playSong(Game["songs"][0])
  405. Game["songIndex"] = 0
  406. }
  407.  
  408. if(typeof i == "string"){
  409. if(Game["maxPlayers"]<0){
  410. Game["maxPlayers"]=parseInt(i)
  411. }
  412. var alivePercent = (parseInt(i)-1)/Game["maxPlayers"]
  413. if(alivePercent <= songThresholds[Game["songIndex"]+1]){
  414. console.log(Game["songIndex"])
  415. Game["songIndex"]++
  416. playSong(Game["songs"][Game["songIndex"]])
  417. }
  418. }
  419.  
  420. }
  421.  
  422. var gameOver99 = Game['prototype']['GameOver'].toString();
  423. gameOver99 = "Game['updateSong'](-1);Game['song'].pause();Game['song'].currentTime=0;" + trim(gameOver99)
  424. Game['prototype']['GameOver'] = new Function(gameOver99)
  425.  
  426. var printSlot99 = SlotView['prototype']['printSlotPlace'].toString()
  427. var printSlotParams = getParams(printSlot99);
  428. printSlot99 = `Game["updateSong"](this['slot']['gs']['p']['getPlaceColor'](${printSlotParams[0]})['str']);` + trim(printSlot99)
  429. SlotView['prototype']['printSlotPlace'] = new Function(...printSlotParams, printSlot99);
  430.  
  431.  
  432.  
  433. var readyGo99 = Game['prototype']['restart'].toString()
  434. 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)
  435. Game['prototype']['restart'] = new Function(readyGo99);
  436.  
  437. var specMode99 = Live['prototype']['spectatorMode'].toString()
  438. var specParams = getParams(specMode99);
  439. specMode99 = `Game['updateSong'](-1);` + trim(specMode99)
  440. Live['prototype']['spectatorMode'] = new Function(...specParams, specMode99);
  441.  
  442. var paint99 = Game['prototype']['paintMatrixWithColor'].toString()
  443. var paintParams = getParams(paint99);
  444. paint99 = `Game['updateSong'](-1);` + trim(paint99)
  445. Game['prototype']['paintMatrixWithColor'] = new Function(...paintParams, paint99);
  446.  
  447.  
  448. localStorage.mainVol = localStorage.mainVol || "100"
  449. document.getElementById("settingsSave").addEventListener("click", function(){localStorage.mainVol=document.getElementById('vol-control').value}, false);
  450. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  451.  
  452. //remove these 3 lines if you dont want the music to stop for the countdown
  453. var readyGo992 = Game['prototype']['readyGo'].toString()
  454. readyGo992 = "Game['updateSong'](-1);" + trim(readyGo992)
  455. Game['prototype']['readyGo'] = new Function(readyGo992);
  456. }
  457.  
  458. });
  459. })();