Hello Kitty Tetris Theme

Hello Kitty Tetris theme for Jstris

  1. // ==UserScript==
  2. // @name Hello Kitty Tetris Theme
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.15
  5. // @description Hello Kitty Tetris theme for Jstris
  6. // @author Eddie, orth0dox
  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. loadSkin("https://i.imgur.com/m9m6rn2.png",58);
  17. loadGhostSkin("https://i.imgur.com/pp0nuw0.png",58);
  18.  
  19. //Custom Grid
  20. bgLayer.style.display="none";
  21. var newItem = document.createElement("table");
  22. newItem.style.background = "rgb(100,80,90)";
  23. newItem.style.borderCollapse = "separate";
  24. newItem.style.borderSpacing = "4px";
  25. newItem.style.marginTop = "-2px";
  26. newItem.style.marginLeft = "-2px";
  27. newItem.style.width = bgLayer.width-4 + "px";
  28. newItem.style.height = bgLayer.height+4 + "px";
  29. newItem.innerHTML = ("<tr>"+"<td style='border:3px solid rgb(92,72,82); border-radius:4px;;'></td>".repeat(10)+"</tr>").repeat(20)
  30. stage.insertBefore(newItem, stage.childNodes[0]);
  31.  
  32. //Jstris Custom Background Image
  33. document.head.getElementsByTagName("style")[0].innerHTML="";
  34. document.body.style.backgroundImage="url('https://i.imgur.com/Znhy8Gd.png')";
  35. document.body.style.backgroundSize="100% 100%";
  36. document.getElementById("app").style.backgroundColor="rgba(0, 0, 0, 0)";
  37. document.getElementById("app").style.height="1000px";
  38.  
  39.  
  40. //Jstris SFX
  41. CustomSFXset.prototype = new BaseSFXset;
  42. loadSFX(new CustomSFXset);
  43.  
  44. });
  45. })();
  46.  
  47. function CustomSFXset(){
  48. this.volume=1;
  49. this.lock={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_lock.mp3",abs:1};
  50. this.died={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_died.mp3",abs:1,set:1};
  51. this.hold={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_hold.mp3",abs:1,set:0};
  52. this.move={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_move.mp3",abs:1,set:0};
  53. this.linefall={url:"blank.wav",abs:1,set:0};
  54. };
  55.  
  56. /**************************
  57. Rotation Sounds Script
  58. **************************/
  59.  
  60. Game['rotationSounds'] = [
  61. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_rotate.mp3", //rotate left
  62. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_rotate.mp3", //rotate right
  63. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_rotate.mp3" //rotate 180°
  64. ];
  65.  
  66. Game['rotationVolumes'] = [1,1,1]
  67.  
  68. localStorage.evVol=localStorage.evVol||"100"
  69.  
  70. Game["rArray"]=[];
  71. 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)}})
  72.  
  73.  
  74. 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())}
  75.  
  76.  
  77. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  78. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  79.  
  80. var rotFunc = Game['prototype']['rotateCurrentBlock'].toString()
  81. var rotParams = getParams(rotFunc)
  82.  
  83. var rotInsert = 'var rotPos=[0,0,1,2]['+rotParams[0]+'+1];console.log(rotPos);Game.rArray[rotPos]&&playRotSound(rotPos);'
  84.  
  85. rotFunc = rotInsert + trim(rotFunc)
  86.  
  87. Game['prototype']['rotateCurrentBlock'] = new Function(...rotParams, rotFunc);
  88.  
  89. /**************************
  90. Opponent's Field Grid Script
  91. **************************/
  92.  
  93. var customStyle=document.createElement("style");
  94. customStyle.innerHTML='.players .bgLayer{display:none;}';
  95. document.body.appendChild(customStyle);
  96.  
  97. /**************************
  98. Special Events Script
  99. **************************/
  100. (function() {
  101. window.addEventListener('load', function(){
  102.  
  103. Game['eventSounds'] = [
  104. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_linefall.mp3",
  105. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_linefall.mp3",
  106. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_linefall.mp3",
  107. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_linefall.mp3",
  108. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_linefall.mp3",
  109. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_linefall.mp3",
  110. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_linefall.mp3",
  111. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_clear4.mp3",
  112. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_linefall.mp3",
  113. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_linefall.mp3",
  114. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKT_clear4.mp3"
  115. ];
  116.  
  117. Game['eventVolumes'] = [1,1,1,1,1,1,1,1,1,1,1]
  118.  
  119.  
  120. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","PERFECT_CLEAR"]
  121. window.enableB2B = true;
  122.  
  123.  
  124. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  125. 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)}})
  126.  
  127.  
  128. var evVol = document.createElement("tr");
  129. 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>`
  130. tab_sound.appendChild(evVol);
  131.  
  132. if(typeof playSound != 'function') {
  133. 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())}
  134. }
  135.  
  136.  
  137. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","PERFECT_CLEAR"]
  138.  
  139. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  140. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  141.  
  142.  
  143. var clcFunc = Game['prototype']['checkLineClears'].toString()
  144. var clcParams = getParams(clcFunc)
  145. searchFor = "[_" + clcFunc.split("switch")[1].split("]][_")[2]
  146.  
  147. events.map((x,i)=>{
  148. replacement = searchFor.replace("[","[Game['btb']=this['isBack2Back'],Game['latestEv']='"+x+"',")
  149. clcFunc=clcFunc.replace(searchFor,replacement)
  150. })
  151.  
  152. Game['prototype']["checkLineClears"] = new Function(...clcParams, trim(clcFunc));
  153.  
  154. var psFunc = Game['prototype']['playSound'].toString()
  155. var psParams = getParams(psFunc);
  156. 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)
  157. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  158.  
  159. localStorage.mainVol = localStorage.mainVol || "100"
  160. document.getElementById("settingsSave").addEventListener("click", function(){
  161. localStorage.mainVol=document.getElementById('vol-control').value
  162. }, false);
  163.  
  164. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  165.  
  166.  
  167. /**************************
  168. Songs Script
  169. **************************/
  170.  
  171.  
  172. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  173. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  174.  
  175.  
  176. localStorage.musicVol = localStorage.musicVol || "100";
  177. localStorage.SPvol = localStorage.SPvol || "100";
  178.  
  179. var musicVol = document.createElement("tr");
  180. 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>'
  181. tab_sound.appendChild(musicVol);
  182.  
  183. var spVol = document.createElement("tr");
  184. 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>'
  185. tab_sound.appendChild(spVol);
  186.  
  187.  
  188.  
  189. Game["setVol"] = function(vol,mode) {
  190. if(mode){
  191. localStorage.musicVol = vol
  192. volSetting.innerHTML=vol+'%';
  193. var musicVol=document.getElementById("volControl")
  194. Game["songs"].map(x=>{
  195. x.volume = (musicVol.value/100);
  196. })
  197. } else {
  198. localStorage.SPvol = vol
  199. volSetting2.innerHTML=vol+'%';
  200. var spVol=document.getElementById("volControl2")
  201. Game["song"].volume = spVol.value/100
  202. }
  203. }
  204.  
  205.  
  206. if(typeof Game != "undefined"){
  207.  
  208.  
  209. var songsMP = [
  210. "https://ecdldaiiere.github.io/Eddiez-Soundz/HKTsong1.mp3",
  211. ]
  212.  
  213. var songSP = "https://ecdldaiiere.github.io/Eddiez-Soundz/HKTsong1.mp3"
  214.  
  215. var songThresholds = [1]
  216.  
  217. Game['onlySprint'] = false;
  218.  
  219.  
  220. window.playSong = function(s) {
  221. Game["songs"].map(x=>{
  222. x.pause();
  223. x.currentTime = 0;
  224. })
  225. Game["song"].pause();
  226. Game["song"].currentTime = 0;
  227.  
  228. if(s != undefined){
  229. !s.paused&&0<s.currentTime?s.currentTime=0:s.play()
  230. }
  231. }
  232.  
  233. Game["songs"] = [];
  234. Game["maxPlayers"] = 0
  235. Game["songIndex"] = -1
  236.  
  237.  
  238. Game["song"] = document.createElement("audio");
  239. Game["song"].src = songSP;
  240. Game["song"].loop = true;
  241. Game["song"].volume = 1;
  242.  
  243. songsMP.map((x,i)=>{
  244. Game["songs"].push(document.createElement("audio"));
  245. Game["songs"][i].src = x;
  246. Game["songs"][i].loop = true;
  247. Game["songs"][i].volume = 1;
  248. })
  249.  
  250. Game["setVol"](localStorage.musicVol,1)
  251. Game["setVol"](localStorage.SPvol,0)
  252.  
  253.  
  254. Game["updateSong"] = function(i) {
  255.  
  256. if(i<0){
  257. Game["maxPlayers"] = 0
  258. playSong()
  259. Game["songIndex"] = -1
  260. }
  261.  
  262. if(i==0){
  263. Game["maxPlayers"]= -1
  264. playSong(Game["songs"][0])
  265. Game["songIndex"] = 0
  266. }
  267.  
  268. if(typeof i == "string"){
  269. if(Game["maxPlayers"]<0){
  270. Game["maxPlayers"]=parseInt(i)
  271. }
  272. var alivePercent = (parseInt(i)-1)/Game["maxPlayers"]
  273. if(alivePercent <= songThresholds[Game["songIndex"]+1]){
  274. console.log(Game["songIndex"])
  275. Game["songIndex"]++
  276. playSong(Game["songs"][Game["songIndex"]])
  277. }
  278. }
  279.  
  280. }
  281.  
  282. var gameOver99 = Game['prototype']['GameOver'].toString();
  283. gameOver99 = "Game['updateSong'](-1);Game['song'].pause();Game['song'].currentTime=0;" + trim(gameOver99)
  284. Game['prototype']['GameOver'] = new Function(gameOver99)
  285.  
  286. var printSlot99 = SlotView['prototype']['printSlotPlace'].toString()
  287. var printSlotParams = getParams(printSlot99);
  288. printSlot99 = `Game["updateSong"](this['slot']['gs']['p']['getPlaceColor'](${printSlotParams[0]})['str']);` + trim(printSlot99)
  289. SlotView['prototype']['printSlotPlace'] = new Function(...printSlotParams, printSlot99);
  290.  
  291.  
  292.  
  293. var readyGo99 = Game['prototype']['restart'].toString()
  294. 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)
  295. Game['prototype']['restart'] = new Function(readyGo99);
  296.  
  297. var specMode99 = Live['prototype']['spectatorMode'].toString()
  298. var specParams = getParams(specMode99);
  299. specMode99 = `Game['updateSong'](-1);` + trim(specMode99)
  300. Live['prototype']['spectatorMode'] = new Function(...specParams, specMode99);
  301.  
  302. var paint99 = Game['prototype']['paintMatrixWithColor'].toString()
  303. var paintParams = getParams(paint99);
  304. paint99 = `Game['updateSong'](-1);` + trim(paint99)
  305. Game['prototype']['paintMatrixWithColor'] = new Function(...paintParams, paint99);
  306.  
  307. localStorage.mainVol = localStorage.mainVol || "100"
  308. document.getElementById("settingsSave").addEventListener("click", function(){localStorage.mainVol=document.getElementById('vol-control').value}, false);
  309. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  310.  
  311.  
  312. //remove these 3 lines if you dont want the music to stop for the countdown
  313. var readyGo992 = Game['prototype']['readyGo'].toString()
  314. readyGo992 = "Game['updateSong'](-1);" + trim(readyGo992)
  315. Game['prototype']['readyGo'] = new Function(readyGo992);
  316. }
  317.  
  318. });
  319. })();