smoothretro82

TW Converter 1.0: convert Textwall.cc art to Tw.2s4.me format

Dec 1st, 2025 (edited)
59
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. (function(){
  2. if(document.getElementById('twHud')) return; // Prevent multiple HUDs
  3.  
  4. // HUD container
  5. const hud = document.createElement('div');
  6. hud.id = 'twHud';
  7. hud.style.cssText = `
  8. position: fixed;
  9. top: 50px;
  10. left: 50px;
  11. width: 400px;
  12. height: 350px;
  13. background: #2f2f2f; /* dark grey background */
  14. color: #e0e0e0; /* light grey text */
  15. border: 2px solid #555;
  16. border-radius: 8px;
  17. padding: 10px;
  18. z-index: 99999;
  19. font-family: monospace;
  20. user-select: none;
  21. cursor: default;
  22. display: flex;
  23. flex-direction: column;
  24. box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  25. `;
  26. hud.innerHTML = `
  27. <div id="twHudHeader" style="
  28. display: flex;
  29. justify-content: space-between;
  30. align-items: center;
  31. cursor: grab;
  32. margin-bottom: 8px;
  33. font-weight: bold;
  34. color: #e0e0e0;
  35. ">
  36. <span>TW Converter HUD</span>
  37. <div>
  38. <button id="clearHud" style="
  39. background: #555;
  40. border: none;
  41. color: #e0e0e0;
  42. font-weight: bold;
  43. cursor: pointer;
  44. border-radius: 3px;
  45. margin-right: 5px;
  46. ">Clear</button>
  47. <button id="closeHud" style="
  48. background: #d9534f;
  49. border: none;
  50. color: white;
  51. font-weight: bold;
  52. cursor: pointer;
  53. border-radius: 3px;
  54. ">X</button>
  55. </div>
  56. </div>
  57.  
  58. <textarea id="newformat" placeholder="Paste text from Textwall.cc here" style="width:100%; flex:1; resize:none; background:#3a3a3a; color:#e0e0e0; border:1px solid #555; padding:5px;"></textarea>
  59. <br>
  60. <input type="checkbox" id="removeoverline" checked><span>remove overline</span>
  61. <br><br>
  62. <button id="convertbtn" style="width:100%; padding:5px; background:#5cb85c; color:white; border:none; border-radius:3px; cursor:pointer;">Convert</button>
  63. <br><br>
  64. <button id="aboutBtn" style="width:100%; padding:5px; margin-bottom:5px; background:#0275d8; color:white; border:none; border-radius:3px; cursor:pointer;">About</button>
  65. <textarea id="oldformat" placeholder="Old format will appear here" readonly style="width:100%; flex:1; resize:none; background:#3a3a3a; color:#e0e0e0; border:1px solid #555; padding:5px;"></textarea>
  66. <button id="selectallbtn" style="width:100%; padding:5px; margin-top:5px; background:#777; color:white; border:none; border-radius:3px; cursor:pointer;">Select All</button>
  67. <div id="resizeHandle" style="
  68. width: 15px;
  69. height: 15px;
  70. background: #555;
  71. position: absolute;
  72. right: 0;
  73. bottom: 0;
  74. cursor: se-resize;
  75. border-bottom-right-radius: 8px;
  76. "></div>
  77. `;
  78. document.body.appendChild(hud);
  79.  
  80. // Drag HUD
  81. const header = document.getElementById('twHudHeader');
  82. header.onmousedown = function(e) {
  83. let shiftX = e.clientX - hud.getBoundingClientRect().left;
  84. let shiftY = e.clientY - hud.getBoundingClientRect().top;
  85.  
  86. function moveAt(pageX, pageY) {
  87. hud.style.left = pageX - shiftX + 'px';
  88. hud.style.top = pageY - shiftY + 'px';
  89. }
  90.  
  91. function onMouseMove(e) {
  92. moveAt(e.pageX, e.pageY);
  93. }
  94.  
  95. document.addEventListener('mousemove', onMouseMove);
  96.  
  97. document.onmouseup = function() {
  98. document.removeEventListener('mousemove', onMouseMove);
  99. document.onmouseup = null;
  100. };
  101. };
  102. header.ondragstart = () => false;
  103.  
  104. // Close HUD
  105. document.getElementById('closeHud').onclick = () => hud.remove();
  106.  
  107. // Clear top textarea
  108. document.getElementById('clearHud').onclick = () => {
  109. document.getElementById('newformat').value = '';
  110. };
  111.  
  112. // Resize HUD
  113. const resizeHandle = document.getElementById('resizeHandle');
  114. resizeHandle.onmousedown = function(e) {
  115. e.preventDefault();
  116. document.onmousemove = function(e) {
  117. hud.style.width = e.clientX - hud.getBoundingClientRect().left + 'px';
  118. hud.style.height = e.clientY - hud.getBoundingClientRect().top + 'px';
  119. };
  120. document.onmouseup = function() {
  121. document.onmousemove = null;
  122. document.onmouseup = null;
  123. };
  124. };
  125.  
  126. // Conversion logic
  127. function convert(string) {
  128. var idx = string.indexOf("\x1b");
  129. if(idx===-1) return string;
  130. var text = string.slice(0, idx);
  131. try {
  132. var fmt = atob(string.slice(idx + 1));
  133. } catch(e) {
  134. return string; // invalid base64
  135. }
  136. var convertedFmt = "";
  137. for (let i = 0; i < fmt.length; i += 2) {
  138. var fmtCode = fmt.charCodeAt(i) + fmt.charCodeAt(i + 1) * 256;
  139. var decorations = Math.floor(fmtCode / 31);
  140. if (document.getElementById('removeoverline').checked) decorations &= ~16;
  141. var colors = fmtCode % 31;
  142. var convertedFmtCode = colors + decorations * 31;
  143. convertedFmt += String.fromCharCode(convertedFmtCode + 192);
  144. }
  145. return `${text}\x1b${convertedFmt}`;
  146. }
  147.  
  148. // Convert button
  149. document.getElementById('convertbtn').onclick = () => {
  150. document.getElementById('oldformat').value = convert(document.getElementById('newformat').value);
  151. };
  152.  
  153. // Select All button
  154. document.getElementById('selectallbtn').onclick = () => {
  155. const output = document.getElementById('oldformat');
  156. output.select();
  157. };
  158.  
  159. // About button
  160. document.getElementById('aboutBtn').onclick = () => {
  161. alert("TW Converter\nVersion 1.0 - 12/1/2025 \nCreated by dominoguy_\nConverts art from Textwall.cc to Tw.2s4.me format.");
  162. };
  163. })();
  164.  
Comments
Add Comment
Please, Sign In to add comment