OWOT Toolbox

Useful tools for OWOT.

目前为 2024-10-10 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name OWOT Toolbox
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-10-09
  5. // @description Useful tools for OWOT.
  6. // @author rnd-guy
  7. // @match https://ourworldoftext.com/*
  8. // @match https://test.ourworldoftext.com/*
  9. // @icon https://ourworldoftext.com/static/favicon.png
  10. // @grant none
  11. // @license GNU GPLv3
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. var version = "1.2.2";
  18. // Toolbox title
  19. menu.addEntry("<h2 style='background: linear-gradient(180deg, red,orange);-webkit-text-fill-color: transparent;-webkit-background-clip: text;background-clip: text;' id='tb-title'>OWOT<br>TOOLBOX</h2><h4>Version " + version + "</h4>")
  20. // Colors & rate-limit detection
  21. if(state.worldModel.color_text>0){alert("WARNING\n========================\nColors are disabled on this world.\nThis affects the Stickman Script.")}
  22. /* // Chars per second detection
  23. if(state.worldModel.char_rate[1]<513){
  24. if(state.worldModel.char_rate[1]<100){
  25. alert("WARNING\n========================\nThis world has a very low characters per second value.\nThis heavily affects all scripts.")
  26. } else {
  27. alert("!!!WARNING!!!\n========================\nThis world has a low characters per second value.\nThis affects all scripts.")
  28. }
  29. }
  30. /**/
  31. if(state.worldModel.char_rate[1]>2000){
  32. alert("!!!WARNING!!!\n========================\nThis world has a high rate-limit.\nScripts WILL be slow.")
  33. }
  34. // Automatic paste permission bypass.
  35. if(state.worldModel.feature_paste>0){
  36. (function(){Permissions.can_paste = function() {return true;};})();
  37. console.log("No pasting detected - Bypassed");
  38. }
  39. menu.addOption("View rate limit",function(){alert("Rate limit: " + state.worldModel.char_rate[0].toString() + " chars per " + state.worldModel.char_rate[1].toString() + "ms")});
  40. /* Instant Write (previously InstaPaste) v1.1
  41. Supports linebreaks.
  42. */
  43. function instapaste(str,col,loc) {
  44. var scriptloc = loc;
  45. var originalloc = loc;
  46. for(let i=0;i<str.length;i++){
  47. var char = str.charAt(i)
  48. var charsintostring = "-" + i+1
  49. if(char !== "°") {
  50. writeCharTo(char,0x000000,...scriptloc);
  51. scriptloc = coordinateAdd(...scriptloc,0,0,1,0);
  52. } else {
  53. originalloc = coordinateAdd(...originalloc,0,0,0,1)
  54. scriptloc = originalloc;
  55. console.log(originalloc + ", " + loc + ", " + scriptloc)
  56. }
  57. }
  58. }
  59. function aa(){
  60. var kk=prompt("what text to write?\nUse ° for linebreaks :)");
  61. instapaste(kk,0x000000,cursorCoords);
  62. }
  63. menu.addOption("Instant Write",aa)
  64.  
  65. // FILL SCRIPT
  66. var symbl = " "
  67. var timewait = 0;
  68. function wait(ms) {
  69. return new Promise(resolve => setTimeout(resolve, ms));
  70. }
  71.  
  72. async function ccc() {
  73. w.setFlushInterval(0);
  74. var e = [...""];
  75.  
  76. var r = async (r, t, o, n) => {
  77. for (var $ = 16 * r[0] + r[2], a = 8 * r[1] + r[3], i = 16 * t[0] + t[2], c = 8 * t[1] + t[3], l = $; l <= i; l++) {
  78. for (var F = a; F <= c; F++) {
  79. var v = getCharInfoXY(l, F);
  80. if (16777215 !== v.color && 1 !== v.protection) {
  81. writeCharToXY(symbl, charColor, l, F, null, false, false, false, false);
  82. }
  83. if (timewait!==0) {
  84. await wait(timewait); // Wait for 100 milliseconds before continuing
  85. }
  86. }
  87. }
  88. };
  89.  
  90. menu.addOption("Fill Area", () => {
  91. var e = RegionSelection();
  92. e.init();
  93. e.onselection(r);
  94. e.startSelection();
  95. });
  96.  
  97. console.log('Check the menu for the "Fill" button');
  98. }
  99. ccc();
  100.  
  101. menu.addOption("Change Symbol", () => {
  102. symbl = prompt("What symbol to fill with?\n(Leave empty for wiping)");
  103. if (symbl == "") {
  104. symbl = " ";
  105. }
  106. });
  107. menu.addOption("Change Fill Speed", () => {
  108. timewait = prompt("Set delay between each character (in miliseconds). Useful to bypass rate-limits.\nSet to 0 to instantly wipe.\nLeave empty for 0 ms");
  109. timewait = timewait.replace(/[^0-9]/g);
  110. if(timewait=="") {
  111. timewait = "0";
  112. }
  113. timewait = parseInt(timewait, 10);
  114. });
  115. // Stickman Script
  116. // Variable setup
  117. var col = 0x000000;
  118. var col_h = col;
  119. var col_la = col;
  120. var col_ra = col;
  121. var col_ll = col;
  122. var col_rl = col;
  123. var col_body = col;
  124. var loc = [];
  125. // Modals setup
  126. // Limb colors modal
  127. const colormodal2 = new Modal()
  128. colormodal2.createForm()
  129. colormodal2.setFormTitle("Stickman limb colors")
  130. var head = colormodal2.addEntry("Head color","color");
  131. var leftarm = colormodal2.addEntry("Left arm color","color");
  132. var rightarm = colormodal2.addEntry("Right arm color","color");
  133. var body = colormodal2.addEntry("Body color","color");
  134. var leftleg = colormodal2.addEntry("Left leg color","color");
  135. var rightleg = colormodal2.addEntry("Right leg color","color");
  136. colormodal2.onSubmit(function setColors() {
  137. col_h = parseInt(head.input.value,16);
  138. col_la = parseInt(leftarm.input.value,16)
  139. col_ra = parseInt(rightarm.input.value,16)
  140. col_ll = parseInt(leftleg.input.value,16)
  141. col_rl = parseInt(rightleg.input.value,16)
  142. col_body = parseInt(body.input.value,16)
  143. });
  144. // Single color modal
  145. const colormodal = new Modal();
  146. colormodal.createForm();
  147. var stickcolor = colormodal.addEntry("Stickman color","color");
  148. colormodal.setFormTitle("Stickman color. This will override any previously set limb colors.");
  149. colormodal.onSubmit(function setStickCol() {
  150. col = parseInt(stickcolor.input.value,16);
  151. console.log(stickcolor.input.value);
  152. col_h = col;
  153. col_la = col;
  154. col_ra = col;
  155. col_ll = col;
  156. col_rl = col;
  157. col_body = col;
  158. });
  159. col_h = col;
  160. col_la = col;
  161. col_ra = col;
  162. col_ll = col;
  163. col_rl = col;
  164. col_body = col;
  165. // Stickman paster function
  166. function stickman(){
  167. loc = cursorCoords;
  168. writeCharTo("O",col_h,...loc)// Head
  169. loc = coordinateAdd(...loc,0,0,-1,1)
  170. writeCharTo("/",col_la,...loc)// Left arm
  171. loc = coordinateAdd(...loc,0,0,1,0)
  172. writeCharTo("|",col_body,...loc)// Body
  173. loc = coordinateAdd(...loc,0,0,1,0)
  174. writeCharTo('\\',col_ra,...loc)//Right arm
  175. loc = coordinateAdd(...loc,0,0,-2,1)
  176. writeCharTo("/",col_ll,...loc)//Left leg
  177. loc = coordinateAdd(...loc,0,0,2,0)
  178. writeCharTo('\\',col_rl,...loc)//Right leg
  179. console.log(col_h + " " + col_la + " " + col_body + " " + col_ra + " " + col_ll + " " + col_rl);
  180. }
  181. // Menu options to access the modals
  182. menu.addOption("Add Stickman",()=>{stickman()});
  183. menu.addOption("Set Stickman Color",()=>{
  184. colormodal.open()
  185. });
  186. menu.addOption("Set Limb Colors",()=>{
  187. colormodal2.open()
  188. });
  189.  
  190. w.doAnnounce("OWOT Toolbox Loaded - v" + version + " - Enjoy :)");
  191. })();