Fast Linesplit (like fast split)

try to take over the world!!

当前为 2023-02-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fast Linesplit (like fast split)
  3. // @namespace Put your cursor on top of on of the dots and press U
  4. // @version 0.1
  5. // @description try to take over the world!!
  6. // @author Net#1872
  7. // @license GPL-3.0-or-later
  8. // @match https://cellcraft.io/
  9. // @match https://agma.io/
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. var split = "U"
  14. window.addEventListener('keydown', keydown);
  15. setTimeout(function() {
  16. split = split.charCodeAt(0)
  17.  
  18. }, 50)
  19. function tripleSplit(){
  20. $("#canvas").trigger($.Event("keydown", { keyCode: 84}));
  21. $("#canvas").trigger($.Event("keyup", { keyCode: 84}));
  22. }
  23. function freezeKey() {
  24. $("#canvas").trigger($.Event("keydown", { keyCode: 70}));
  25. $("#canvas").trigger($.Event("keyup", { keyCode: 70}));
  26. }
  27.  
  28. function keydown(event) {
  29. if(event.keyCode == split){
  30. tripleSplit()
  31. setTimeout(freezeKey, 115)
  32. setTimeout(freezeKey, 165)
  33. }
  34. }
  35.  
  36.  
  37.  
  38. $("head").append(`<style>
  39. .point {
  40. background-color:#333;
  41. }
  42.  
  43. .point:hover {
  44. background-color: orange;
  45. }
  46. </style>`);
  47.  
  48. //Credit to wynell for the window.innerHeight and window.innerWidth
  49.  
  50. let [w, h] = [, window.innerHeight]
  51. $('body').append(`
  52. <div class="point" id="point-top" onclick="tripleSplit()" style="border: 2px solid white; border-radius: 100%; width: 15px; height: 15px; position: fixed; left: ${
  53. window.innerWidth / 2
  54. }px; top: ${0}px; transform: translate(-50%, -50%);"></div>
  55. <div class="point" id="point-right" onclick="tripleSplit()" style="border: 2px solid white; border-radius: 100%; width: 15px; height: 15px; position: fixed; left: ${
  56. window.innerWidth
  57. }px; top: ${window.innerHeight / 2}px; transform: translate(-50%, -50%);"></div>
  58. <div class="point" id="point-bottom" onclick="tripleSplit()" style="border: 2px solid white; border-radius: 100%; width: 15px; height: 15px; position: fixed; left: ${
  59. window.innerWidth / 2
  60. }px; top: ${window.innerHeight}px; transform: translate(-50%, -50%);"></div>
  61. <div class="point" id="point-left" onclick="tripleSplit()" style="border: 2px solid white; border-radius: 100%; width: 15px; height: 15px; position: fixed; left: ${0}px; top: ${
  62. window.innerHeight / 2
  63. }px; transform: translate(-50%, -50%);"></div>
  64. </div>`)
  65. $('#settingTab3,.rab-radius').click(function (e) {
  66. $('#roleSettings').css('display', 'block')
  67. $('#cLinesplitOverlay')
  68. .removeAttr('disabled')
  69. .parent()
  70. .parent()
  71. .css('display', 'block')
  72. })
  73. $('.hotkey-col')
  74. .eq(1)
  75. .append(
  76. `Linesplit overlay <div id="keyLinesplitOverlay" class="hotkey-input-2"></div><br>`
  77. )
  78. $('#roleSettings').append(
  79. `<div class="role-setting"><label><input id="cLinesplitOverlay" type="checkbox"}><span> Linesplit overlay</span></label><br></div>`
  80. )
  81. $(window).resize(function (e) {
  82. let [w, h] = [window.innerWidth, window.innerHeight]
  83. $('#point-top')
  84. .css('left', `${window.innerWidth / 2}px`)
  85. .css('top', `${0}px`)
  86. $('#point-right')
  87. .css('left', `${window.innerWidth}px`)
  88. .css('top', `${window.innerHeight / 2}px`)
  89. $('#point-bottom')
  90. .css('left', `${window.innerWidth / 2}px`)
  91. .css('top', `${window.innerHeight}px`)
  92. $('#point-left')
  93. .css('left', `${0}px`)
  94. .css('top', `${window.innerHeight / 2}px`)
  95. })
  96.