🏠 Home 

Greasy Fork is available in English.

School Theme

T99's theme for Jstris


Installer dette script?
  1. // ==UserScript==
  2. // @name School Theme
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.16
  5. // @description T99's theme for Jstris
  6. // @author Eddie
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11. (function() {
  12. 'use strict';
  13. window.addEventListener('load', function(){
  14. loadSkin("https://i.imgur.com/7B5u4Bq.png",48);
  15. loadGhostSkin("https://i.imgur.com/xWdcuPN.png",48);
  16. //Jstris Custom Background Image
  17. document.head.getElementsByTagName("style")[0].innerHTML="";
  18. document.body.style.backgroundImage="url('https://i.imgur.com/FJ7DwjB.png')";
  19. document.body.style.backgroundSize="100% 100%";
  20. document.getElementById("app").style.backgroundColor="rgba(0, 0, 0, 0)";
  21. document.getElementById("app").style.height="1000px";
  22. //Jstris SFX
  23. CustomSFXset.prototype = new BaseSFXset;
  24. loadSFX(new CustomSFXset);
  25. });
  26. })();
  27. function CustomSFXset(){
  28. this.volume=1;
  29. this.lock={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/School_lock.wav",abs:1};
  30. this.ready={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/t99ready.wav",abs:1,set:1};
  31. this.go={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/t99go.wav",abs:1,set:0};
  32. this.died={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/t99died.wav",abs:1,set:1};
  33. this.hold={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/School_hold.wav",abs:1,set:0};
  34. this.move={url:"https://ecdldaiiere.github.io/Eddiez-Soundz/School_move.wav",abs:1,set:0};
  35. this.linefall={url:"blank.wav",abs:1,set:0};
  36. };
  37. /************************************
  38. T99 Grid Script
  39. ************************************/
  40. (function() {
  41. window.addEventListener('load', function(){
  42. customFieldBorder = true //change to false to disable
  43. if(customFieldBorder){
  44. if(typeof Game != "undefined"){
  45. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  46. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  47. function atGameStart() {
  48. bgLayer.width = 500
  49. bgLayer.height = 650
  50. bgLayer.style.left = "-"+((880-248)/2)/2+"px"
  51. bgLayer.style.top = "-"+((1080-480)/2)/2+"px"
  52. this.drawBgGrid(1);
  53. var bgctx = bgLayer.getContext("2d");
  54. var img = new Image;
  55. img.onload = function(){
  56. bgctx.clearRect(0, 0, 880, 1080);
  57. bgctx.drawImage(img,58,120,880/2,1080/2); // Or at whatever offset you like
  58. };
  59. img.src = "https://i.imgur.com/3SG6BBa.png";
  60. sprintInfo.style.zIndex = "100000";
  61. }
  62. var initRandom = GameCore['prototype']['initRandomizer'].toString()
  63. var initRandomParams = getParams(initRandom)
  64. initRandom = trim(atGameStart.toString()) + trim(initRandom)
  65. GameCore['prototype']['initRandomizer'] = new Function(...initRandomParams, initRandom);
  66. var queueC = queueCanvas.getBoundingClientRect();
  67. for (var i = 0; i < 5; i++) {
  68. var qCC = document.createElement("canvas");
  69. qCC.id = "queueCopy" + i
  70. qCC.className = "queueCopy"
  71. qCC.style.position = "absolute";
  72. qCC.style.left = queueC.left+"px";
  73. qCC.style.top = queueC.top+(72*i)+"px";
  74. qCC.height=72
  75. i&&(qCC.style.transform = "translatey("+(72*i)+") ")
  76. qCC.width=queueCanvas.width
  77. document.body.appendChild(qCC)
  78. }
  79. var customStyleQueue=document.createElement("style");
  80. customStyleQueue.innerHTML='#queueCanvas {visibility:hidden;} .queueCopy {z-index:1} #holdCanvas {z-index:2}';
  81. document.body.appendChild(customStyleQueue);
  82. var updateQueueBoxFunc = Game['prototype']['updateQueueBox'].toString()
  83. var inject = `;for (var i = 0; i < 5; i++) {
  84. var destCanvas = document.getElementById("queueCopy"+i)
  85. var destCtx = destCanvas.getContext('2d');
  86. destCtx.clearRect(0, 0, destCanvas.width, destCanvas.height);
  87. destCtx.drawImage(queueCanvas, 0, -i*72);}`
  88. updateQueueBoxFunc = trim(updateQueueBoxFunc) + inject
  89. Game['prototype']["updateQueueBox"] = new Function(updateQueueBoxFunc);
  90. queueCopies = [queueCopy0,queueCopy1,queueCopy2,queueCopy3,queueCopy4]
  91. i=0
  92. queueCopies.map(x=>{
  93. x.style.transform += "scale(0.5,0.5)"
  94. x.style.transform += "translate(-75px,"+ -i*40 +"px)"
  95. i++
  96. })
  97. holdCanvas.style.float = "none"
  98. holdCanvas.style.position = "absolute"
  99. holdCanvas.style.transform = "scale(0.5,0.5)"
  100. holdCanvas.style.top = "2px"
  101. holdCanvas.style.left = "28px"
  102. rInfoBox.style.position = "absolute"
  103. rInfoBox.style.zIndex = 100
  104. rInfoBox.style.marginLeft = "90px"
  105. rInfoBox.style.transform = "scale(0.8,0.8)"
  106. stage.style.left = "112px"}
  107. }
  108. });
  109. })();
  110. /**************************
  111. Rotation Sounds Script
  112. **************************/
  113. Game['rotationSounds'] = [
  114. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_rotate.wav", //rotate left
  115. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_rotate.wav", //rotate right
  116. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_rotate.wav" //rotate 180°
  117. ];
  118. Game['rotationVolumes'] = [1,1,1]
  119. localStorage.evVol=localStorage.evVol||"100"
  120. Game["rArray"]=[];
  121. 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)}})
  122. 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())}
  123. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  124. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  125. var rotFunc = Game['prototype']['rotateCurrentBlock'].toString()
  126. var rotParams = getParams(rotFunc)
  127. var rotInsert = 'var rotPos=[0,0,1,2]['+rotParams[0]+'+1];console.log(rotPos);Game.rArray[rotPos]&&playRotSound(rotPos);'
  128. rotFunc = rotInsert + trim(rotFunc)
  129. Game['prototype']['rotateCurrentBlock'] = new Function(...rotParams, rotFunc);
  130. /**************************
  131. Special Events Script
  132. **************************/
  133. (function() {
  134. window.addEventListener('load', function(){
  135. Game['eventSounds'] = [
  136. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_tspinsingle.mp3",
  137. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_tspinsingle.mp3",
  138. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_clear1.wav",
  139. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_tspindouble.mp3",
  140. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_clear2.wav",
  141. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_clear3.wav",
  142. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_tspintriple.mp3",
  143. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_clear4.wav",
  144. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_clear5.mp3",
  145. "https://ecdldaiiere.github.io/Eddiez-Soundz/t99_perfectclear.wav",
  146. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_tspindouble.mp3",
  147. "https://ecdldaiiere.github.io/Eddiez-Soundz/School_b2btetris.mp3"
  148. ];
  149. Game['eventVolumes'] = [1,1,1,1,1,1,1,1,1,1,1,1]
  150. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  151. window.enableB2B = true;
  152. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  153. 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)}})
  154. var evVol = document.createElement("tr");
  155. 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>`
  156. tab_sound.appendChild(evVol);
  157. if(typeof playSound != 'function') {
  158. 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())}
  159. }
  160. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","CLEAR5","PERFECT_CLEAR"]
  161. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  162. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  163. var clcFunc = Game['prototype']['checkLineClears'].toString()
  164. var clcParams = getParams(clcFunc)
  165. searchFor = "[_" + clcFunc.split("switch")[1].split("]][_")[2]
  166. events.map((x,i)=>{
  167. replacement = searchFor.replace("[","[Game['btb']=this['isBack2Back'],console.log('"+x+"'),Game['latestEv']='"+x+"',")
  168. clcFunc=clcFunc.replace(searchFor,replacement)
  169. })
  170. Game['prototype']["checkLineClears"] = new Function(...clcParams, trim(clcFunc));
  171. var psFunc = Game['prototype']['playSound'].toString()
  172. var psParams = getParams(psFunc);
  173. psFunc = `
  174. if(Game["latestEv"]){
  175. sIndex=events.indexOf(Game["latestEv"]);
  176. console.log(sIndex)
  177. sound=sIndex;enableB2B&&Game.btb&&~[0,1,3,5,7,8].indexOf(sIndex)&&(sound=10+ +(7==sIndex));
  178. console.log(sound);
  179. Game.sArray[sound]&&playSound(sound);
  180. Game["latestEv"]="";
  181. }` + trim(psFunc)
  182. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  183. localStorage.mainVol = localStorage.mainVol || "100"
  184. document.getElementById("settingsSave").addEventListener("click", function(){
  185. localStorage.mainVol=document.getElementById('vol-control').value
  186. }, false);
  187. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  188. /**************************
  189. Opponent's Field Grid Script
  190. **************************/
  191. var customStyle=document.createElement("style");
  192. customStyle.innerHTML='.players .bgLayer{display:none;}';
  193. document.body.appendChild(customStyle);
  194. /**************************
  195. Songs Script
  196. **************************/
  197. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  198. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  199. localStorage.musicVol = localStorage.musicVol || "100";
  200. localStorage.SPvol = localStorage.SPvol || "100";
  201. var musicVol = document.createElement("tr");
  202. 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>'
  203. tab_sound.appendChild(musicVol);
  204. var spVol = document.createElement("tr");
  205. 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>'
  206. tab_sound.appendChild(spVol);
  207. Game["setVol"] = function(vol,mode) {
  208. if(mode){
  209. localStorage.musicVol = vol
  210. volSetting.innerHTML=vol+'%';
  211. var musicVol=document.getElementById("volControl")
  212. Game["songs"].map(x=>{
  213. x.volume = (musicVol.value/100);
  214. })
  215. } else {
  216. localStorage.SPvol = vol
  217. volSetting2.innerHTML=vol+'%';
  218. var spVol=document.getElementById("volControl2")
  219. Game["song"].volume = spVol.value/100
  220. }
  221. }
  222. if(typeof Game != "undefined"){
  223. var songsMP = [
  224. "https://ecdldaiiere.github.io/Eddiez-Soundz/Schoolsong1.mp3",
  225. "https://ecdldaiiere.github.io/Eddiez-Soundz/Schoolsong2.wav",
  226. "https://ecdldaiiere.github.io/Eddiez-Soundz/Schoolsong3.wav"
  227. ]
  228. var songSP = "https://ecdldaiiere.github.io/Eddiez-Soundz/Schoolsong1.mp3"
  229. //Play song when only X*100% of players are left (first one is always 1)
  230. var songThresholds = [1, 0.6, 0.2]
  231. Game['onlySprint'] = false;
  232. window.playSong = function(s) {
  233. Game["songs"].map(x=>{
  234. x.pause();
  235. x.currentTime = 0;
  236. })
  237. Game["song"].pause();
  238. Game["song"].currentTime = 0;
  239. if(s != undefined){
  240. !s.paused&&0<s.currentTime?s.currentTime=0:s.play()
  241. }
  242. }
  243. Game["songs"] = [];
  244. Game["maxPlayers"] = 0
  245. Game["songIndex"] = -1
  246. Game["song"] = document.createElement("audio");
  247. Game["song"].src = songSP;
  248. Game["song"].loop = true;
  249. Game["song"].volume = 1;
  250. songsMP.map((x,i)=>{
  251. Game["songs"].push(document.createElement("audio"));
  252. Game["songs"][i].src = x;
  253. Game["songs"][i].loop = true;
  254. Game["songs"][i].volume = 1;
  255. })
  256. Game["setVol"](localStorage.musicVol,1)
  257. Game["setVol"](localStorage.SPvol,0)
  258. Game["updateSong"] = function(i) {
  259. if(i<0){
  260. Game["maxPlayers"] = 0
  261. playSong()
  262. Game["songIndex"] = -1
  263. }
  264. if(i==0){
  265. Game["maxPlayers"]= -1
  266. playSong(Game["songs"][0])
  267. Game["songIndex"] = 0
  268. }
  269. if(typeof i == "string"){
  270. if(Game["maxPlayers"]<0){
  271. Game["maxPlayers"]=parseInt(i)
  272. }
  273. var alivePercent = (parseInt(i)-1)/Game["maxPlayers"]
  274. if(alivePercent <= songThresholds[Game["songIndex"]+1]){
  275. console.log(Game["songIndex"])
  276. Game["songIndex"]++
  277. playSong(Game["songs"][Game["songIndex"]])
  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. var printSlot99 = SlotView['prototype']['printSlotPlace'].toString()
  285. var printSlotParams = getParams(printSlot99);
  286. printSlot99 = `Game["updateSong"](this['slot']['gs']['p']['getPlaceColor'](${printSlotParams[0]})['str']);` + trim(printSlot99)
  287. SlotView['prototype']['printSlotPlace'] = new Function(...printSlotParams, printSlot99);
  288. var readyGo99 = Game['prototype']['restart'].toString()
  289. 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)
  290. Game['prototype']['restart'] = new Function(readyGo99);
  291. var specMode99 = Live['prototype']['spectatorMode'].toString()
  292. var specParams = getParams(specMode99);
  293. specMode99 = `Game['updateSong'](-1);` + trim(specMode99)
  294. Live['prototype']['spectatorMode'] = new Function(...specParams, specMode99);
  295. var paint99 = Game['prototype']['paintMatrixWithColor'].toString()
  296. var paintParams = getParams(paint99);
  297. paint99 = `Game['updateSong'](-1);` + trim(paint99)
  298. Game['prototype']['paintMatrixWithColor'] = new Function(...paintParams, paint99);
  299. localStorage.mainVol = localStorage.mainVol || "100"
  300. document.getElementById("settingsSave").addEventListener("click", function(){localStorage.mainVol=document.getElementById('vol-control').value}, false);
  301. Settings['prototype']['volumeChange'](+localStorage.mainVol)
  302. //remove these 3 lines if you dont want the music to stop for the countdown
  303. var readyGo992 = Game['prototype']['readyGo'].toString()
  304. readyGo992 = "Game['updateSong'](-1);" + trim(readyGo992)
  305. Game['prototype']['readyGo'] = new Function(readyGo992);
  306. }
  307. });
  308. })();