KİNG WHOWHERE V2

Garti.io da olan otaqları rahatlıqla izləmənizi təmin edər

  1. // ==UserScript==
  2. // @name KİNG WHOWHERE V2
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Garti.io da olan otaqları rahatlıqla izləmənizi təmin edər
  6. // @author KİNG
  7. // @match https://gartic.io/?king2
  8. // @icon data:image/gif;https://lh3.googleusercontent.com/a/ACg8ocI2MjKyE-4hqdU3u44cGzhdfkAW8I7JhUUAr1U0O6JFAB8Pqg4r=s300
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. if (window.location.href.indexOf("?king2") !== -1) {
  13. let leftContent = document.createElement("div");
  14. leftContent.setAttribute("style", "position:fixed; top:0; left:0; width:30%; height:100vh; background:#111; border-right:5px solid silver; padding:10px; box-sizing:border-box; overflow-y:auto; color:#f1f1f1; z-index:9999;");
  15. leftContent.classList.add("leftcontent");
  16.  
  17. let rightContent = document.createElement("div");
  18. rightContent.setAttribute("style", "position:fixed; top:0; left:30%; width:70%; height:100vh; background:#111; padding:10px; box-sizing:border-box; z-index:9999;");
  19. rightContent.classList.add("rightcontent");
  20.  
  21. let header = `<div style="background-color:#000; color:#FFD700; padding:10px; text-align:center; font-weight:bold;">Developer by King</div>`;
  22. let iframeBorderStyle = "border:5px solid gold;";
  23. let headerIframe = `<div style="text-align:center; color:blue; font-weight:bold; margin-bottom:10px;">WhoWhere by King</div>`;
  24.  
  25. let themeSelect = `
  26. <select style='width:100%; padding:10px; margin-bottom:10px; background:#333; color:#f1f1f1; border-radius:5px;' onchange='window.refreshrooms()' class='themeselect'>
  27. <option value="">Tema Seç</option>
  28. <option value="&subject[]=1"mumi</option>
  29. <option value="&subject[]=2">Heyvanlar</option>
  30. <option value="&subject[]=3">Obyektlər</option>
  31. <option value="&subject[]=4">Yeməklər</option>
  32. <option value="&subject[]=5">Feillər</option>
  33. <option value="&subject[]=6">Peşələr</option>
  34. <option value="&subject[]=7">Pokemon</option>
  35. <option value="&subject[]=8">Filmlər</option>
  36. <option value="&subject[]=9">Cizgi Filmləri</option>
  37. <option value="&subject[]=10">Mahnılar</option>
  38. <option value="&subject[]=11">LoL</option>
  39. <option value="&subject[]=12">Oyunlar</option>
  40. <option value="&subject[]=13">Məşhurlar</option>
  41. <option value="&subject[]=14">Marvel / DC</option>
  42. <option value="&subject[]=15">TV serialları</option>
  43. <option value="&subject[]=16">Bayraqlar</option>
  44. <option value="&subject[]=17">Futbol</option>
  45. <option value="&subject[]=18">Harry Potter</option>
  46. <option value="&subject[]=19">Clash Royale</option>
  47. <option value="&subject[]=20">Lord of Rings</option>
  48. <option value="&subject[]=21">Game of Thrones</option>
  49. <option value="&subject[]=22">Dragon Ball</option>
  50. <option value="&subject[]=23">Dota</option>
  51. <option value="&subject[]=24">Youtuberlər</option>
  52. <option value="&subject[]=25">Yayımçılar</option>
  53. <option value="&subject[]=26">Loqo</option>
  54. <option value="&subject[]=27">Qruplar</option>
  55. <option value="&subject[]=28">Animelər</option>
  56. <option value="&subject[]=29"dman</option>
  57. <option value="&subject[]=30">Başqaları / Ümumi</option>
  58. <option value="&subject[]=31">Minecraft</option>
  59. <option value="&subject[]=32">Fortnite</option>
  60. <option value="&subject[]=33">FNAF</option>
  61. <option value="&subject[]=34">Star Wars</option>
  62. <option value="&subject[]=35">Naruto</option>
  63. <option value="&subject[]=36">The Sims</option>
  64. <option value="&subject[]=37">Hallowem</option>
  65. <option value="&subject[]=38">Anorma Tema</option>
  66. </select>`;
  67.  
  68. let searchInput = "<input type='text' style='width:100%; padding:10px; margin-bottom:10px; background:#333; color:#f1f1f1; border-radius:5px;' placeholder='Otaq axtar' oninput='window.refreshrooms(this.value)' class='searchparam' />";
  69. let roomList = "<div class='rooms' style='overflow-y:scroll; height:80%;'></div>";
  70.  
  71. leftContent.innerHTML = themeSelect + searchInput + roomList;
  72. document.body.appendChild(leftContent);
  73. document.body.appendChild(rightContent);
  74.  
  75. function _(x) { return document.querySelector(x); }
  76. function _a(x) { return document.querySelectorAll(x); }
  77.  
  78. window.filterRooms = (rooms, search) => {
  79. return rooms.filter(room => room.code.toLowerCase().includes(search.toLowerCase()));
  80. }
  81.  
  82. window.refreshrooms = (search = "") => {
  83. const themeValue = _(".themeselect").value;
  84. fetch("https://gartic.io/req/list?search=" + search + "&language[]=23" + themeValue).then(response => response.json()).then(data => {
  85. let roomdatas = window.filterRooms(data, search);
  86.  
  87. let favorites = JSON.parse(localStorage.getItem('favorites')) || [];
  88. let favoriteRooms = roomdatas.filter(room => favorites.includes(room.code));
  89. let otherRooms = roomdatas.filter(room => !favorites.includes(room.code));
  90.  
  91. _(".rooms").innerHTML = "";
  92.  
  93. const createRoomElement = (room) => `
  94. <div class="room" style="position:relative; display:flex; flex-direction:column; background:#222; font-size:11pt; color:#f1f1f1; border-radius:20px; margin-top:10px; padding:20px; font-weight:bold; cursor:pointer;" onclick='window.openInIframe("https://gartic.io/${room.code}/viewer", "${room.code}")' data-code="${room.code}">
  95. <img class="roomico" src="https://gartic.io/static/images/subjects/${room.subject}.svg" style="width:40px; height:40px; margin-right:10px;" />
  96. <div class="roominfo">#${room.code.slice(-3)} ${room.quant}/${room.max}</div>
  97. <input type="checkbox" id="favorite-${room.code}" style="position:absolute; top:10px; right:10px;" ${favorites.includes(room.code) ? 'checked' : ''} title="Sevimli olaraq seç" onclick='window.toggleFavorite("${room.code}", event)'/>
  98. <button style="position:absolute; bottom:10px; right:10px; padding:5px 10px; background:red; color:black; border:none; border-radius:5px; cursor:pointer;" onclick='window.openRoom("${room.code}", event)'>►</button>
  99. </div>`;
  100.  
  101. _(".rooms").innerHTML += favoriteRooms.map(createRoomElement).join('');
  102. _(".rooms").innerHTML += otherRooms.map(createRoomElement).join('');
  103. });
  104. }
  105.  
  106. window.openInIframe = (url, roomCode) => {
  107. _(".rightcontent").innerHTML = `${headerIframe}<iframe src="${url}" style="width:100%; height:90%; border:none; border-radius:20px; box-shadow:10px 10px 10px black; ${iframeBorderStyle}"></iframe>`;
  108. document.querySelectorAll('.room .watching-indicator').forEach(el => el.remove());
  109. const roomElement = document.querySelector(`.room[data-code="${roomCode}"]`);
  110. if (roomElement) {
  111. roomElement.insertAdjacentHTML('beforeend', '<div class="watching-indicator" style="color: gold; margin-top: 10px;">Otaq İzlənilir</div>');
  112. }
  113. }
  114.  
  115. window.openRoom = (roomCode, event) => {
  116. event.stopPropagation();
  117. window.open(`https://gartic.io/${roomCode}`, '_blank');
  118. }
  119.  
  120. window.toggleFavorite = (roomCode, event) => {
  121. event.stopPropagation();
  122. let favorites = JSON.parse(localStorage.getItem('favorites')) || [];
  123. if (favorites.includes(roomCode)) {
  124. favorites = favorites.filter(code => code !== roomCode);
  125. _(`#favorite-${roomCode}`).checked = false;
  126. } else {
  127. favorites.push(roomCode);
  128. _(`#favorite-${roomCode}`).checked = true;
  129. }
  130. localStorage.setItem('favorites', JSON.stringify(favorites));
  131. window.refreshrooms();
  132. }
  133.  
  134. window.addEventListener('load', () => {
  135. window.refreshrooms();
  136. });
  137. }