Splatoon Theme

Splatoon Theme for Jstris

当前为 2019-11-24 提交的版本,查看 最新版本

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