Special Events Script

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

目前为 2019-06-18 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Special Events Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  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.  
  18. Game['eventSounds'] = [
  19. "http://k007.kiwi6.com/hotlink/jf1s9pn5p6/vo_tspinsingle.mp3",
  20. "http://k007.kiwi6.com/hotlink/eow52erj3s/vo_tspinmini.mp3",
  21. "",
  22. "http://k007.kiwi6.com/hotlink/irakdcqe4u/vo_tspindouble.mp3",
  23. "http://k007.kiwi6.com/hotlink/cp5u6gk6fb/vo_lne02.mp3",
  24. "http://k007.kiwi6.com/hotlink/kcwahy6476/vo_tspintriple.mp3",
  25. "http://k007.kiwi6.com/hotlink/dnoo8aqt18/vo_lne03.mp3",
  26. "http://k007.kiwi6.com/hotlink/iaw7q5l3wm/vo_tetrs.mp3",
  27. "http://k007.kiwi6.com/hotlink/rcmr3ffx0h/vo_happy.mp3",
  28. "http://k007.kiwi6.com/hotlink/sg6evdo4ks/vo_b2btspin.mp3",
  29. "http://k007.kiwi6.com/hotlink/lxhjlwbc53/vo_b2btetrs.mp3"
  30. ];
  31.  
  32. Game['eventVolumes'] = [1,1,1,1,1,1,1,1,1,1,1]
  33.  
  34.  
  35. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","PERFECT_CLEAR"]
  36. window.enableB2B = true;
  37.  
  38.  
  39. Game["latestEv"]="";Game["sArray"]=[];localStorage.evVol=localStorage.evVol||"100";window.b2bBefore=false;
  40. 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)}})
  41.  
  42.  
  43. var evVol = document.createElement("tr");
  44. 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>`
  45. tab_appear.appendChild(evVol);
  46.  
  47. if(typeof playSound != 'function') {
  48. 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())}
  49. }
  50.  
  51. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  52. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  53.  
  54. var clcFunc = Game['prototype']['checkLineClears'].toString()
  55. events.map((x,i)=>{clcFunc=clcFunc.replace(x+")",x+");Game['btb']=this['isBack2Back'];Game['latestEv']='"+x+"';");})
  56. Game['prototype']["checkLineClears"] = new Function(trim(clcFunc));
  57.  
  58. var psFunc = Game['prototype']['playSound'].toString()
  59. var psParams = getParams(psFunc);
  60. 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)
  61. Game['prototype']['playSound'] = new Function(...psParams, psFunc);
  62.  
  63.  
  64. });
  65. })();