Fast Left and Rejoin

Fast Left and Auto Rejoin

  1. // ==UserScript==
  2. // @name Fast Left and Rejoin
  3. // @description Fast Left and Auto Rejoin
  4. // @version 1.0
  5. // @author STRAGON
  6. // @license N/A
  7. // @match *://gartic.io/*
  8. // @match *://*/*?__cpo=aHR0cHM6Ly9nYXJ0aWMuaW8
  9. // @icon https://static.cdnlogo.com/logos/s/96/st.svg
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @grant GM_addValueChangeListener
  13. // @grant GM_addStyle
  14. // @grant GM_openInTab
  15. // @namespace https://greasyfork.org/en/users/1353946-stragon-x
  16.  
  17. // ==/UserScript==
  18.  
  19. (function() {
  20. let originalSend = WebSocket.prototype.send;
  21. let setTrue = false;
  22.  
  23. window.wsObj = {};
  24.  
  25. WebSocket.prototype.send = function(data) {
  26. console.log("Gönderilen Veri: " + data);
  27. originalSend.apply(this, arguments);
  28. if (Object.keys(window.wsObj).length == 0) {
  29. window.wsObj = this;
  30. window.eventAdd();
  31. }
  32. };
  33. window.eventAdd = () => {
  34.  
  35. if (!setTrue) {
  36.  
  37. setTrue = 1;
  38.  
  39. window.wsObj.addEventListener("message", (msg) => {
  40. let data = JSON.parse(msg.data.slice(2));
  41. if (data[0] == 5) {
  42. window.wsObj.lengthID = data[1];
  43. window.wsObj.id = data[2];
  44. }
  45. });
  46. }
  47. };
  48.  
  49. let ready=0,oldurl;
  50. let panelx = document.createElement("div");
  51. panelx.setAttribute("class","roomspanel");
  52. panelx.setAttribute("style","width:0%;height:auto;max-height:0px;overflow-y:scroll;padding:10px;position:fixed;background-color:white;color:grey;font-weight:bold;right:10px;top:50%;transform:translate(0,-50%);border-radius:10px;border:2px solid grey;text-align:center;z-index:99999;");
  53. let icerik = "<h2>Odalar</h2><hr><br><input type='text' style='padding:10px;' placeholder='Oda Ara..' oninput='window.refreshrooms(this.value)' class='mousetrap' /><br><br><div class='odaliste'></div>";
  54. function _(x){return document.querySelector(x);};
  55. function _a(x){return document.querySelectorAll(x);};
  56. window.refresh=(x=window.location.href)=>{window.onbeforeunload=null;oldurl=x;_("#exit").click();_(".ic-yes").click();setTimeout(window.location.href=oldurl,500);};
  57.  
  58. setTimeout(()=>{
  59. if(document.title.indexOf("#")!=-1){
  60. let l = setInterval(()=>{
  61. _(".ic-playHome").click();
  62. clearInterval(l);
  63. },100);
  64. }
  65. },300);
  66.  
  67. window.refreshrooms=(x="")=>{
  68. let roomdatas;
  69. fetch("https://gartic.io/req/list?search="+x+"&language[]=8").then(x=>x.json()).then(x=>{
  70. roomdatas=x;
  71. _(".odaliste").innerHTML="";
  72. for(let i of roomdatas){
  73. _(".odaliste").innerHTML+="<button style='width:70%;text-align:center;background-color:dodgerblue;color:white;border:2px solid cyan;border-radius:10px;padding:10px;' onclick='window.refresh(\"https://gartic.io/"+i.code+"\")'><b>"+i.code.slice(-3)+" - "+i.quant+"/"+i.max+"</b></button><a href='https://gartic.io/"+i.code+"/viewer' target='_blank'>Viewer</a><br>";
  74. }
  75. });
  76. }
  77.  
  78. document.body.addEventListener("keyup",(event)=>{
  79. window.event.keyCode==27?window.refresh():0;
  80. })
  81.  
  82. let a = setInterval(()=>{
  83. if(_(".game")){
  84. if(ready==0){
  85. setTimeout(()=>{
  86. _(".logo").remove();
  87. if(!_(".roomspanel")){
  88. document.body.appendChild(panel);
  89. _(".roomspanel").innerHTML=icerik;
  90. window.refreshrooms();
  91. }
  92. for(let i of _a(".alert")){
  93. i.setAttribute("class","msg");
  94. }
  95. _(".user.you").innerHTML+='<span style="padding:10px;background:black;color:gold;font-weight:bold;">VIP</span>';
  96. ready=1;
  97. },300);
  98. }
  99. _(".contentPopup")?_(".btYellowBig.ic-yes").click():0;
  100. _("g")?_("g").remove():0;
  101. if(ready==1){
  102. for(let i of _a(".scrollElements")[2].querySelectorAll(".msg.alert")){
  103. i.innerText.split(", ")[1].split(" ")[0] == _(".user.you").innerText.split("\n")[0]?window.refresh():0;
  104. }
  105. }
  106. }
  107. },50);
  108.  
  109.  
  110. GM_addStyle(`
  111. #panel {
  112. position: fixed;
  113. top: 60px;
  114. left: 5px;
  115. padding: 10px;
  116. display: flex;
  117. flex-direction: column;
  118. align-items: center;
  119. z-index: 999999;
  120. }
  121. #panel img {
  122. width: 40px;
  123. height: 40px;
  124. margin-bottom: 10px;
  125. }
  126. `);
  127.  
  128. let panel = document.createElement('div');
  129. panel.id = 'panel';
  130. let img = document.createElement('img');
  131.  
  132. img.src = 'https://static-00.iconduck.com/assets.00/exit-icon-1821x2048-izrubw8d.png';
  133. img.onclick = function() {
  134. window.wsObj.send(`42[24,${window.wsObj.id}]`);
  135. location.reload();
  136. };
  137.  
  138. panel.appendChild(img);
  139.  
  140.  
  141. document.body.appendChild(panel);
  142. })();
  143.