smoothretro1982

FastCleaner & Paster 1.9 (w.i.p) by DG_

Apr 20th, 2026 (edited)
250
0
Never
6
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.16 KB | None | 0 0
  1. (function() {
  2. // =========================================================================
  3. // USER CONFIGURATION (Adjust speeds here)
  4. // =========================================================================
  5. const CONFIG = {
  6. PASTE_SPEED: 64, // Characters per second (e.g., 64, 128, 256)
  7. CLEAR_DELAY: 10 // Milliseconds to wait between clearing each coordinate
  8. };
  9. // =========================================================================
  10.  
  11. // 1. Setup Global State
  12. window.clearState = window.clearState || {
  13. isRunning: false,
  14. _abortInternal: false
  15. };
  16.  
  17. /**
  18. * Core Logic: Paste from Clipboard
  19. * Instantly schedules writing tasks using the configured speed.
  20. */
  21. window.pasteToArea = async function(startX, startY) {
  22. if (window.clearState.isRunning) return w.showToast("Task already running.");
  23.  
  24. try {
  25. const rawText = await navigator.clipboard.readText();
  26. if (!rawText) return w.showToast("Clipboard is empty.");
  27.  
  28. // Strip carriage returns to keep grid alignment accurate
  29. const text = rawText.replace(/\r/g, "");
  30.  
  31. window.clearState.isRunning = true;
  32. window.clearState._abortInternal = false;
  33. w.showToast(`Pasting queued at ${startX}, ${startY} (~${CONFIG.PASTE_SPEED} char/s)...`);
  34.  
  35. let currentX = startX;
  36. let currentY = startY;
  37. let typedCount = 0;
  38.  
  39. // Dynamically calculate millisecond spacing based on config
  40. const MS_PER_CHAR = 1000 / CONFIG.PASTE_SPEED;
  41.  
  42. for (let i = 0; i < text.length; i++) {
  43. const char = text[i];
  44.  
  45. if (char === "\n") {
  46. currentX = startX;
  47. currentY++;
  48. continue;
  49. }
  50.  
  51. if (char === " ") {
  52. currentX++;
  53. continue;
  54. }
  55.  
  56. // Scope variables for the async execution block
  57. const targetX = currentX;
  58. const targetY = currentY;
  59. const targetChar = char;
  60. const executionDelay = typedCount * MS_PER_CHAR;
  61.  
  62. // Non-blocking schedule
  63. setTimeout(() => {
  64. if (window.clearState._abortInternal) return;
  65. w.tp(targetX, targetY);
  66. w.typeChar(targetChar, 1);
  67. }, executionDelay);
  68.  
  69. currentX++;
  70. typedCount++;
  71. }
  72.  
  73. // Reset execution states when the background scheduler finishes
  74. setTimeout(() => {
  75. w.showToast(window.clearState._abortInternal ? "Paste stopped." : "Paste complete!");
  76. window.clearState.isRunning = false;
  77. window.clearState._abortInternal = false;
  78. }, typedCount * MS_PER_CHAR);
  79.  
  80. } catch (err) {
  81. w.showToast("Error: Clipboard access denied. Focus the window!");
  82. window.clearState.isRunning = false;
  83. }
  84. };
  85.  
  86. /**
  87. * Core Logic: Clear Area
  88. * Uses the configured clearing delay.
  89. */
  90. window.clearArea = async function(x1, y1, x2, y2) {
  91. if (window.clearState.isRunning) return w.showToast("Wait! Task in progress.");
  92.  
  93. const startX = Math.min(x1, x2), endX = Math.max(x1, x2);
  94. const startY = Math.min(-y1, -y2), endY = Math.max(-y1, -y2);
  95.  
  96. window.clearState.isRunning = true;
  97. window.clearState._abortInternal = false;
  98.  
  99. try {
  100. let count = 0;
  101. for (let y = startY; y <= endY; y++) {
  102. for (let x = startX; x <= endX; x++) {
  103. if (window.clearState._abortInternal) break;
  104.  
  105. const hasCheck = typeof getCharInfoXY === "function";
  106. const info = hasCheck ? getCharInfoXY(x, y) : null;
  107.  
  108. if (!hasCheck || !info || (info && info.char !== " ")) {
  109. w.tp(x, y);
  110. w.typeChar(" ", 1);
  111. count++;
  112. await new Promise(r => setTimeout(r, CONFIG.CLEAR_DELAY));
  113. }
  114. }
  115. if (window.clearState._abortInternal) break;
  116. }
  117. w.showToast(window.clearState._abortInternal ? `Cleared stopped. Cleared ${count} coordinates.` : `Finished. Cleared ${count} coordinates.`);
  118. } finally {
  119. window.clearState.isRunning = false;
  120. window.clearState._abortInternal = false;
  121. }
  122. };
  123.  
  124. /**
  125. * Stop Command (Authorized)
  126. */
  127. window.stop = function(user) {
  128. if (user === "dominoguy_") {
  129. window.clearState._abortInternal = true;
  130. w.showToast("Stop command accepted.");
  131. } else {
  132. w.showToast("Access Denied.");
  133. }
  134. };
  135.  
  136. /**
  137. * Command Parser
  138. */
  139. window.cmd = function(input) {
  140. const parts = input.toString().trim().split(/\s+/);
  141. const action = parts[0].toLowerCase();
  142.  
  143. if (action === "paste") {
  144. let x = parseInt(parts[1]);
  145. let y = parseInt(parts[2]);
  146.  
  147. const finalX = isNaN(x) ? (typeof cursor !== "undefined" ? cursor.x : 0) : x;
  148. const finalY = isNaN(y) ? (typeof cursor !== "undefined" ? cursor.y : 0) : y;
  149.  
  150. window.pasteToArea(finalX, finalY);
  151. } else if (action === "stop") {
  152. window.stop("dominoguy_");
  153. } else {
  154. const args = parts.map(n => parseInt(n));
  155. if (args.length === 2 && !isNaN(args[0])) {
  156. window.clearArea(args[0], args[1], args[0], args[1]);
  157. } else if (args.length === 4 && !args.some(isNaN)) {
  158. window.clearArea(args[0], args[1], args[2], args[3]);
  159. } else {
  160. w.showToast("Usage: cmd('paste [x y]'), cmd('stop'), or cmd('x1 y1 [x2 y2]')");
  161. }
  162. }
  163. };
  164.  
  165. w.showToast(`Turbo-Paste Ready! Config: ${CONFIG.PASTE_SPEED} ch/s. Use cmd('paste') at your cursor.`);
  166. })();
Advertisement
Comments
  • smoothretro1982
    102 days
    # text 0.10 KB | 0 0
    1. the first 2 numbers in the command are the upper left corner, and the other 2 are the lower right corner.
  • RubixYT1
    98 days
    # text 0.02 KB | 1 0
    1. i am inspired :D
  • smoothretro1982
    61 days
    1
    # text 0.44 KB | 0 0
    1. Usage Guide
    2.  
    3. Paste at Cursor: Hover your mouse/cursor where you want the text to start and type cmd('paste'). It will use cursor.x and cursor.y automatically.
    4.  
    5. Paste at Manual Coords: Type cmd('paste 100 200') if you want to specify a location regardless of your cursor.
    6.  
    7. Aborting: If you paste a massive wall of text and need to stop, type stop('dominoguy_') or your cursor name.
    8.  
    9. Clearing: Continue using cmd('x1 y1 x2 y2') to wipe areas.
  • smoothretro1982
    56 days
    # text 0.12 KB | 0 0
    1. Be sure to disable "copy colors" & "copy decorations" in the options menu, bc it can't paste colors yet, only b & w.
    2.  
  • smoothretro1982
    54 days
    Comment was deleted
  • smoothretro1982
    54 days
    # text 0.04 KB | 0 0
    1. the y axis is flipped, will fix it later.
    2.  
Add Comment
Please, Sign In to add comment