🏠 Home 

r/place destroyer

Pixel Place Client


Install this script?
  1. // ==UserScript==
  2. // @name r/place destroyer
  3. // @name:ru PP-Client
  4. // @description Pixel Place Client
  5. // @description:ru Pixel Place Клиент
  6. // @version 5.3.5
  7. // @author 0vC4
  8. // @namespace https://greasyfork.org/users/670183
  9. // @match https://pixelplace.io/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=pixelplace.io
  11. // @license MIT
  12. // @grant none
  13. // @run-at document-start
  14. // @require https://greasyfork.org/scripts/438620-workertimer/code/WorkerTimer.js?version=1009025
  15. // @require https://greasyfork.org/scripts/438408-cwss/code/CWSS.js?version=1042744
  16. // @require https://greasyfork.org/scripts/443803-ppml/code/PPML.js?version=1042963
  17. // @require https://greasyfork.org/scripts/443894-ppil/code/PPIL.js?version=1043330
  18. // @require https://greasyfork.org/scripts/443807-ppt/code/PPT.js?version=1045817
  19. // @require https://greasyfork.org/scripts/443844-ppcc/code/PPCC.js?version=1045802
  20. // @require https://greasyfork.org/scripts/443907-pppc/code/PPPC.js?version=1043740
  21. // ==/UserScript==
  22. window.log = console.log;
  23. const PPClient = (() => {
  24. if (window.PPClient) return window.PPClient;
  25. const log = console.log;
  26. const client = {
  27. size: 13,
  28. innerSize: 0,
  29. lock: false,
  30. order: 'fromCenter',
  31. wh: [null, null],
  32. async connect(){
  33. const names = Object.keys(PPPC.settings.userlist);
  34. const arr = [];
  35. PPPC.timer = WorkerTimer;
  36. await PPPC.save();
  37. let n = 0;
  38. for (let i = 0; i < names.length; i++) {
  39. let ws = null;
  40. try {
  41. ws = await PPPC.connect(names[i], 13);
  42. } catch (e) {
  43. ws = null;
  44. }
  45. if (!ws) {
  46. n++;
  47. continue;
  48. }
  49. arr[i-n] = ws;
  50. ws.addEventListener('close', e => arr.splice(arr.indexOf(ws), 1));
  51. }
  52. await PPPC.load();
  53. await PPPC.save();
  54. log(names.length-n, 'bots connected');
  55. client.bots = arr;
  56. },
  57. async disconnect(){
  58. client.bots.filter(Boolean).map(ws => ws.close&&ws.close());
  59. }
  60. };
  61. PPCC.speed = 50;
  62. PPCC.compile(client, PPML, CWSS, WorkerTimer);
  63. client.set = client.safeEmit;
  64. PPT.speed = 20000; // pixels per cycle
  65. PPT.client = client;
  66. client.mode = mode => {
  67. const finish = () => {
  68. if (client.order === 'start' || client.order === 'top') return;
  69. client._posQueue = 0;
  70. PPT.order[client.order]();
  71. };
  72. if (mode == 'none') {
  73. client.onclick = () => true;
  74. return true;
  75. }
  76. if (mode == 'brush') {
  77. client.onclick = (x,y,pixel) => {
  78. PPT.timer = WorkerTimer;
  79. PPT.size = client.size;
  80. PPT.innerSize = client.innerSize;
  81. PPT.pixel = pixel;
  82. PPT.square(x, y, (x,y,p) => client.set(x, y, p), finish);
  83. return false;
  84. };
  85. return true;
  86. }
  87. if (mode == 'rainbow_ring') {
  88. client.onclick = (x,y,pixel) => {
  89. PPT.timer = WorkerTimer;
  90. PPT.size = client.size;
  91. PPT.innerSize = client.innerSize;
  92. PPT.pixel = pixel;
  93. PPT.ring(x, y, (x,y,p) => client.set(x, y, PPT.wheel), finish);
  94. return false;
  95. };
  96. return true;
  97. }
  98. if (mode == 'rainbow_hole') {
  99. client.onclick = (x,y,pixel) => {
  100. PPT.timer = WorkerTimer;
  101. PPT.map = client.map;
  102. const areaSize = 5;
  103. const has = areaSize>>1;
  104. const padding = 2;
  105. const {width, height, pixels} = client.map;
  106. let clr = 0;
  107. let perc = null;
  108. PPT.shader((x,y,p) => {
  109. const dist = ((x-client.map.width/2)**2+(y-client.map.height/2)**2)**0.5;
  110. const percent = 1000*dist/(client.map.height/2)>>0;
  111. if (percent != perc) {
  112. perc = percent;
  113. clr = perc%PPT.palette.length;
  114. while (PPT.palette[clr] == PPT.zero) {
  115. clr++;
  116. if (clr > PPT.palette.length-1) clr = 0;
  117. }
  118. }
  119. client.set(x, y, clr);
  120. }, finish);
  121. return false;
  122. };
  123. return true;
  124. }
  125. if (mode == 'border_rainbow') {
  126. client.onclick = (x,y,pixel) => {
  127. PPT.timer = WorkerTimer;
  128. PPT.map = client.map;
  129. const areaSize = 5;
  130. const has = areaSize>>1;
  131. const padding = 2;
  132. const {width, height, pixels} = client.map;
  133. PPT.shader((x,y,p) => {
  134. if (x < areaSize || x > width-1-areaSize || y < areaSize || y > height-1-areaSize) return;
  135. let start = (x-has)+(y-has)*width;
  136. let area = [];
  137. for (let i = 0; i < areaSize; i++) {
  138. const offset = start+i*width;
  139. area.push(...pixels.slice(offset, offset+areaSize));
  140. }
  141. if (area.find(p => p === 255)) {
  142. client.set(x, y, PPT.wheel);
  143. return;
  144. }
  145. const size = areaSize+padding*2;
  146. const hs = has+padding;
  147. if (x < size || x > width-1-size || y < size || y > height-1-size) return;
  148. start = (x-hs)+(y-hs)*width;
  149. area = [];
  150. for (let i = 0; i < size; i++) {
  151. const offset = start+i*width;
  152. area.push(...pixels.slice(offset, offset+size));
  153. }
  154. if (area.find(p => p === 255)) {
  155. client.set(x, y, 5);
  156. return;
  157. }
  158. client.set(x, y, 5);
  159. }, finish);
  160. return false;
  161. };
  162. return true;
  163. }
  164. if (mode == 'poland') {
  165. client.onclick = (x,y,pixel) => {
  166. PPT.timer = WorkerTimer;
  167. PPT.size = client.size;
  168. PPT.innerSize = client.innerSize;
  169. PPT.pixel = 0;
  170. PPT.square(x, y, (x,y,p) => client.set(x, y, p));
  171. PPT.pixel = 20;
  172. PPT.square(x, y+client.size, (x,y,p) => client.set(x, y, p), finish);
  173. return false;
  174. };
  175. return true;
  176. }
  177. if (mode == 'image') {
  178. client.onclick = (x,y,pixel) => {
  179. PPIL.loadImage(...client.wh)(([pixels, w, h]) => {
  180. PPT.timer = WorkerTimer;
  181. PPT.image(pixels, x,y,w,h, (x,y,p) => client.set(x, y, p), finish);
  182. });
  183. return false;
  184. };
  185. return true;
  186. }
  187. return false;
  188. };
  189. client.lock = true;
  190. client.mode('image');
  191. window.PPClient = client;
  192. return client;
  193. })();
  194. // 0vC4#7152