Greasy Fork 还支持 简体中文。

Special Events Script

allows sounds to be played for special events (eg. T-Spin Double)

目前為 2019-06-13 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Special Events Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description allows sounds to be played for special events (eg. T-Spin Double)
  6. // @author Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. Special Events Script
  13. **************************/
  14. (function() {
  15. window.addEventListener('load', function(){
  16.  
  17. Game['eventSounds'] = [
  18. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_tspinsingle.mp3",
  19. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_tspinminisingle.mp3",
  20. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_clear1.wav",
  21. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_tspindouble.mp3",
  22. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_clear2.mp3",
  23. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_tspintriple.mp3",
  24. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_clear3.mp3",
  25. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_clear4.mp3",
  26. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_perfectclear.mp3",
  27. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_b2btspin.wav",
  28. "https://ecdldaiiere.github.io/Eddiez-Soundz/TOP_b2btetris.mp3"
  29. ];
  30.  
  31. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","PERFECT_CLEAR"]
  32. window.enableB2B = true;
  33.  
  34.  
  35. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  36. 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)}})
  37.  
  38.  
  39. var evVol = document.createElement("tr");
  40. 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>`
  41. tab_appear.appendChild(evVol);
  42.  
  43. if(typeof playSound != 'function') {
  44. window.playSound = function(s){!s.paused&&0<s.currentTime?s.currentTime=0:(s.volume=localStorage.evVol/100,s.play())}
  45. }
  46.  
  47. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  48. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  49.  
  50. var clcFunc = Game['prototype']['checkLineClears'].toString()
  51. events.map((x,i)=>{clcFunc=clcFunc.replace(x+")",x+");Game['btb']=this['isBack2Back'];Game['latestEv']='"+x+"';");})
  52. Game['prototype']["checkLineClears"] = new Function(trim(clcFunc));
  53.  
  54. var psFunc = Game['prototype']['playSound'].toString()
  55. var psParams = getParams(psFunc);
  56. 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)
  57. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  58.  
  59. });
  60. })();