Mxo New Bot Librarys/Depencens - Extensions

For Mxo New Bot - Library/Depencens

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/465113/1185072/Mxo%20New%20Bot%20LibrarysDepencens%20-%20Extensions.js

  1. // ==UserScript==
  2. // @version 1.0
  3. // @author https://github.com/bababoyy
  4. // @license GPLv3
  5. // ==/UserScript==
  6. window.onMxobotLoaded = window.onMxobotLoaded || [];
  7. window.onMxobotLoaded.push(function () {
  8. function filter(tasks) {
  9. return tasks.filter(
  10. (x) =>
  11. x.color != window.MxobotWS.BBY_get_pixel(x.x, x.y) && x.color != -1
  12. );
  13. }
  14.  
  15. function PatternExtensionGenerate(pattern) {
  16. return function () {
  17. Mxobot.Tasker.onTaskAction = function (task) {
  18. if (task == undefined) return;
  19. let chunkCoord = [
  20. Math.floor(task.x / pattern[0].length) * pattern[0].length,
  21. Math.floor(task.y / pattern.length) * pattern.length,
  22. ];
  23. let patternCoord = [task.x - chunkCoord[0], task.y - chunkCoord[1]];
  24. let ascii = pattern[patternCoord[1]][patternCoord[0]];
  25. if (ascii == "p") {
  26. return false;
  27. } else if (ascii == "X") {
  28. task.color = Mxobot.getSelectedColor();
  29. } else {
  30. task.color = ascii.charCodeAt(0) - "0".charCodeAt(0);
  31. }
  32. return true;
  33. };
  34. };
  35. }
  36. var amogus = ["ppppp", "p555p", "5500p", "5555p", "p555p", "p5p5p", "ppppp"];
  37. Mxobot.extensions.push([PatternExtensionGenerate(amogus), "amogus"]);
  38. Mxobot.extensions.push([
  39. PatternExtensionGenerate(["L5", "5L"]),
  40. "gmod missing texture",
  41. ]);
  42.  
  43. Mxobot.extensions.push([
  44. PatternExtensionGenerate(["S", "J", "0", "J", "S"]),
  45. "trans",
  46. ]);
  47. Mxobot.extensions.push([
  48. PatternExtensionGenerate(["D", ">", "<", "8", "Q", "M"]),
  49. "lgbt",
  50. ]);
  51. Mxobot.extensions.push([
  52. PatternExtensionGenerate(["K", "J", "0", "U", "0", "J"]),
  53. "femboy",
  54. ]);
  55.  
  56. Mxobot.extensions.push([
  57. function () {
  58. PatternExtensionGenerate(Mxobot.Menu.pixif)();
  59. },
  60. "Generate pattern by image",
  61. ]);
  62.  
  63. Mxobot.extensions.push([
  64. function () {
  65. var rectsize = 2;
  66. function ontask(task) {
  67. return (
  68. task != undefined &&
  69. (task.y % (rectsize + 1) == 0 || task.x % (rectsize + 1) >= rectsize)
  70. );
  71. }
  72. Mxobot.Tasker.onTaskAction = ontask;
  73. Mxobot.Tasker.onImageTaskReorganize = function (tasks) {
  74. return tasks.filter(ontask);
  75. };
  76. },
  77. "┼ styled pixelating",
  78. ]);
  79. Mxobot.extensions.push([
  80. function () {
  81. /**
  82. * Shuffles array in place.
  83. * @param {Array} a items An array containing the items.
  84. */
  85. function shuffle(a) {
  86. var j, x, i;
  87. for (i = a.length - 1; i > 0; i--) {
  88. j = Math.floor(Math.random() * (i + 1));
  89. x = a[i];
  90. a[i] = a[j];
  91. a[j] = x;
  92. }
  93. return a;
  94. }
  95. Mxobot.Tasker.onImageTaskReorganize = function (tasks) {
  96. tasks = shuffle(tasks);
  97. tasks = filter(tasks);
  98. // change pixelradius from localstorage or keep it as 5
  99. var pixelRadius = localStorage.pixelradius - 0 || 5;
  100. var newTasks = Array.from(tasks);
  101. var pixels = [];
  102. var stucknum = 0;
  103. while (newTasks.length != 0) {
  104. var found_a_match = false;
  105. var task = newTasks.shift();
  106. if (pixels.length == 0) {
  107. pixels.push(task);
  108. found_a_match = true;
  109. } else if (stucknum > newTasks.length) {
  110. pixels = [...pixels, task];
  111. found_a_match = true;
  112. } else {
  113. for (let pixel of pixels) {
  114. if (
  115. (task.x - pixel.x) ** 2 + (task.y - pixel.y) ** 2 <=
  116. pixelRadius ** 2
  117. ) {
  118. pixels.push(task);
  119. found_a_match = true;
  120. break;
  121. }
  122. }
  123. }
  124. if (!found_a_match) {
  125. newTasks.push(task);
  126. stucknum++;
  127. } else {
  128. stucknum = 0;
  129. }
  130. }
  131. return pixels;
  132. };
  133. },
  134. "circledotting",
  135. ]);
  136. Mxobot.extensions.push([
  137. function () {
  138. function coordinate(x, y, ox, oy) {
  139. return [Math.abs(x - ox), Math.abs(y - oy)];
  140. }
  141. Mxobot.Tasker.onImageTaskReorganize = function (
  142. tasks,
  143. width,
  144. height,
  145. cx,
  146. cy
  147. ) {
  148. var [originX, originY] = [
  149. Math.floor(width / 2) + cx,
  150. Math.floor(height / 2) + cy,
  151. ];
  152. tasks.sort(
  153. (pixel1, pixel2) =>
  154. Math.hypot(pixel1.x - originX, pixel1.y - originY) -
  155. Math.hypot(pixel2.x - originX, pixel2.y - originY)
  156. );
  157. return tasks;
  158. };
  159. },
  160. "circlefilling",
  161. ]);
  162.  
  163. Mxobot.extensions.push([
  164. function () {
  165. var colors = Array.from(
  166. document.querySelector("#palette-buttons").children
  167. )
  168. .filter((x) => x.className != "disabled")
  169. .map((x) => parseInt(x.getAttribute("data-id")));
  170. function ontask(task) {
  171. return task;
  172. }
  173. Mxobot.Tasker.onTaskAction = function (task) {
  174. if (task == undefined) return;
  175. task.color = colors[Math.floor(Math.random() * colors.length)];
  176. return true;
  177. };
  178. Mxobot.Tasker.onImageTaskReorganize = function (tasks) {
  179. if (!tasks || tasks.length == 0) {
  180. return [];
  181. }
  182. return tasks.map(function (task) {
  183. if (task == undefined) return;
  184. task.color = colors[Math.floor(Math.random() * colors.length)];
  185. return task;
  186. });
  187. };
  188. },
  189. "war",
  190. ]);
  191. Mxobot.extensions.push([
  192. function () {
  193. var colors = Array.from(
  194. document.querySelector("#palette-buttons").children
  195. )
  196. .filter((x) => x.className != "disabled")
  197. .map((x) => parseInt(x.getAttribute("data-id")));
  198. function ontask(task) {
  199. return task;
  200. }
  201. Mxobot.Tasker.onTaskAction = function (task) {
  202. if (task == undefined) return;
  203. task.color = colors[Math.floor(Math.random() * colors.length)];
  204. return true;
  205. };
  206. Mxobot.Tasker.onImageTaskReorganize = function (tasks) {
  207. if (!tasks || tasks.length == 0) {
  208. return [];
  209. }
  210. return tasks.map(function (task) {
  211. if (task == undefined) return;
  212. task.color = colors[Math.floor(Math.random() * colors.length)];
  213. task.x = tasks[0].x;
  214. task.y = tasks[0].y;
  215. return task;
  216. });
  217. };
  218. },
  219. "war in one pixel",
  220. ]);
  221.  
  222. Mxobot.extensions.push([
  223. function () {
  224. Mxobot.Tasker.onTaskAction = () => true;
  225. Mxobot.Tasker.onImageTaskReorganize = undefined;
  226. },
  227. "Normalize Mxobot.Tasker events",
  228. ]);
  229. var fill_callback;
  230. var fill_ran = false;
  231. Mxobot.extensions.push([
  232. function () {
  233. if (fill_ran == false) {
  234. fill_ran = true;
  235. interact("#canvas").on("click", function () {
  236. if (fill_callback != undefined) {
  237. fill_callback();
  238. }
  239. });
  240. }
  241. let start_coordinate, end_coordinate;
  242. if (fill_callback) {
  243. fill_callback = undefined;
  244. toastr.info("closed fill");
  245. return;
  246. }
  247. toastr.info("opened fill");
  248. fill_callback = function () {
  249. if (start_coordinate) {
  250. end_coordinate = Mxobot.getCoordinates();
  251. let color = Mxobot.getSelectedColor();
  252. if (!color && color != 0) {
  253. return -1;
  254. }
  255. for (let y = start_coordinate[1]; y <= end_coordinate[1]; y++) {
  256. for (let x = start_coordinate[0]; x <= end_coordinate[0]; x++) {
  257. var mvpModeX;
  258. if ((y - start_coordinate[1]) % 2 == 0) {
  259. mvpModeX = x;
  260. } else {
  261. mvpModeX = end_coordinate[0] - x + start_coordinate[0];
  262. }
  263. Mxobot.Tasker._tasks.push({
  264. // @TODO Mxobot.Tasker
  265. x: mvpModeX,
  266. y: y,
  267. color: color,
  268. });
  269. }
  270. }
  271. Mxobot.Tasker._tasks = Mxobot.prepareTasks(Mxobot.Tasker._tasks)
  272. if (Mxobot.Tasker.onImageTaskReorganize) {
  273. Mxobot.Tasker._tasks = Mxobot.Tasker.onImageTaskReorganize(
  274. Mxobot.Tasker._tasks,
  275. end_coordinate[0] - start_coordinate[0],
  276. end_coordinate[1] - start_coordinate[1],
  277. ...start_coordinate
  278. );
  279. }
  280. start_coordinate = undefined;
  281. } else {
  282. start_coordinate = Mxobot.getCoordinates();
  283. }
  284. };
  285. },
  286. "fill",
  287. ]);
  288.  
  289. Mxobot.extensions.push([
  290. function () {
  291. var timeout = prompt(
  292. "Your timeout is " +
  293. localStorage.timeout +
  294. " at the moment. Set timeout to (ms):"
  295. );
  296. if (isNaN(parseInt(timeout))) {
  297. return;
  298. }
  299. localStorage.timeout = parseInt(timeout);
  300. },
  301. "Set timeout",
  302. ]);
  303. Mxobot.extensions.push([
  304. function () {
  305. var name = prompt("Go to user:");
  306. $($('.messages div a[class="user open-profile"]').get(0))
  307. .attr("data-profile", name)
  308. .attr("data-id", name)
  309. .click();
  310. },
  311. "Go to user profile",
  312. ]);
  313. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址