Under PPS Restart Script

restarts game automatically when you go too slow

  1. // ==UserScript==
  2. // @name Under PPS Restart Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description restarts game automatically when you go too slow
  6. // @author Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. Under PPS Restart Script
  13. **************************/
  14. (function() {
  15. window.addEventListener('load', function(){
  16.  
  17. localStorage.restartOption = localStorage.restartOption || "0";
  18. localStorage.restartThreshold = localStorage.restartThreshold || "0";
  19.  
  20. var pbOption = document.createElement("table");
  21. pbOption.innerHTML = `<tbody><tr><td><input name='group'onclick="localStorage.restartOption=0"id='soundPPS'type="radio"><label for="soundPPS">Play a sound</label></td><td><input onclick="localStorage.restartOption=1" id='restartPPS' name='group' type="radio"><label for="restartPPS">Restart the run</label></td></tr><tr><td colspan="2"><span>when PPS goes below <input oninput='localStorage.restartThreshold=this.value'id='threshold'style="width:50px"></span></td></tr></tbody><br>`
  22. tab_other.appendChild(pbOption)
  23.  
  24. document.getElementsByName("group")[+localStorage.restartOption].checked = 1
  25. threshold.value = localStorage.restartThreshold
  26.  
  27. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  28. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  29.  
  30.  
  31. function afterRoundStart() {
  32. window.soundAlreadyPlayed = false;
  33. }
  34.  
  35. var placeBlockFunc = Game['prototype']["startReadyGo"].toString()
  36. placeBlockFunc = trim(placeBlockFunc) + trim(afterRoundStart.toString())
  37. Game['prototype']["startReadyGo"] = new Function(placeBlockFunc);
  38.  
  39.  
  40.  
  41. function afterPlaceBlock() {
  42.  
  43. if(0<threshold.value&&this['clock']>5){
  44. if(this['getPPS']()<+threshold.value&&0!=this['getPPS']()){
  45. if(document.getElementsByName("group")[0].checked&&+localStorage.SE){
  46. var a=new Audio("https://jstris.jezevec10.com/res/se0/fault.wav");
  47. if(vol=document.getElementById("vol-control").value)
  48. a.volume=vol/100;
  49. if(!soundAlreadyPlayed) {
  50. a.play()
  51. soundAlreadyPlayed = true;
  52. }
  53. }
  54. else {
  55. this.GameOver();
  56. this['startPractice'](1)
  57. }
  58. }
  59. };
  60.  
  61. };
  62.  
  63.  
  64.  
  65. var placeBlockFunc = Game['prototype']["placeBlock"].toString()
  66. var params2 = getParams(placeBlockFunc)
  67. placeBlockFunc = trim(placeBlockFunc) + trim(afterPlaceBlock.toString())
  68. Game['prototype']["placeBlock"] = new Function(...params2, placeBlockFunc);
  69.  
  70.  
  71. });
  72. })();