testing

test

当前为 2019-11-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name testing
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description test
  6. // @author Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /************************************
  12. testing
  13. ************************************/
  14. (function() {
  15. window.addEventListener('load', function(){
  16.  
  17.  
  18. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  19. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  20.  
  21. function atGameStart() {
  22. ;console.log(this);
  23.  
  24. bgLayer.width = 880
  25. bgLayer.height = 650
  26. bgLayer.style.left = "-"+((880-248)/2)/2+"px"
  27. bgLayer.style.top = "-"+((1080-480)/2)/2+"px"
  28. this.drawBgGrid(1);
  29. var bgctx = bgLayer.getContext("2d");
  30. var img = new Image;
  31. img.onload = function(){
  32. bgctx.clearRect(0, 0, 880, 1080);
  33. //58
  34. bgctx.drawImage(img,58,120,880/2,1080/2); // Or at whatever offset you like
  35. };
  36. img.src = "https://i.imgur.com/yEQorDE.png";
  37. sprintInfo.style.zIndex = "100000";
  38. console.log('done');
  39. }
  40.  
  41. var initRandom = GameCore['prototype']['initRandomizer'].toString()
  42. var initRandomParams = getParams(initRandom)
  43. initRandom = trim(atGameStart.toString()) + trim(initRandom)
  44. GameCore['prototype']['initRandomizer'] = new Function(...initRandomParams, initRandom);
  45.  
  46.  
  47.  
  48.  
  49. var queueC = queueCanvas.getBoundingClientRect();
  50.  
  51. for (var i = 0; i < 5; i++) {
  52. var qCC = document.createElement("canvas");
  53. qCC.id = "queueCopy" + i
  54. qCC.className = "queueCopy"
  55. qCC.style.position = "absolute";
  56. qCC.style.left = queueC.left+"px";
  57. qCC.style.top = queueC.top+(72*i)+"px";
  58. //qCC.style.top = "calc(50% + "+queueC.top+"px)"
  59. //qCC.style.clipPath = "inset("+73*i+"px 0px 0px 0px)"
  60. qCC.height=72
  61. i&&(qCC.style.transform = "translatey("+(72*i)+") ")
  62. qCC.width=queueCanvas.width
  63. document.body.appendChild(qCC)
  64.  
  65. }
  66.  
  67. var customStyleQueue=document.createElement("style");
  68. customStyleQueue.innerHTML='#queueCanvas {visibility:hidden;} .queueCopy {z-index:1} #holdCanvas {z-index:2}';
  69. document.body.appendChild(customStyleQueue);
  70.  
  71.  
  72. var updateQueueBoxFunc = Game['prototype']['updateQueueBox'].toString()
  73.  
  74. var inject = `;for (var i = 0; i < 5; i++) {
  75. var destCanvas = document.getElementById("queueCopy"+i)
  76. var destCtx = destCanvas.getContext('2d');
  77. destCtx.clearRect(0, 0, destCanvas.width, destCanvas.height);
  78. destCtx.drawImage(queueCanvas, 0, -i*72);}`
  79.  
  80. updateQueueBoxFunc = trim(updateQueueBoxFunc) + inject
  81.  
  82. Game['prototype']["updateQueueBox"] = new Function(updateQueueBoxFunc);
  83.  
  84.  
  85. queueCopies = [queueCopy0,queueCopy1,queueCopy2,queueCopy3,queueCopy4]
  86.  
  87. //shifts third preview 20px to the bottom right
  88. //queueCopy2.style.transform += "translate(20px,20px)"
  89. //scales first preview
  90. //queueCopy0.style.transform += "scale(0.8,0.8)"
  91.  
  92. i=0
  93. queueCopies.map(x=>{
  94. x.style.transform += "scale(0.5,0.5)"
  95. x.style.transform += "translate(-75px,"+ -i*40 +"px)"
  96. i++
  97. })
  98.  
  99.  
  100. holdCanvas.style.float = "none"
  101. holdCanvas.style.position = "absolute"
  102. holdCanvas.style.transform = "scale(0.5,0.5)"
  103. holdCanvas.style.top = "2px"
  104. holdCanvas.style.left = "28px"
  105.  
  106.  
  107. rInfoBox.style.position = "absolute"
  108. rInfoBox.style.zIndex = 100
  109. rInfoBox.style.marginLeft = "100px"
  110.  
  111. stage.style.left = "112px"
  112. //document.getElementsByClassName("mainLayer")[0].style.left = "112px"
  113.  
  114.  
  115.  
  116.  
  117. });
  118. })();