OWOT Toolbox

Useful tools for OWOT.

目前为 2025-03-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name OWOT Toolbox
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-03-17
  5. // @description Useful tools for OWOT.
  6. // @author DefunctUser
  7. // @match https://ourworldoftext.com/*
  8. // @match https://*.ourworldoftext.com/*
  9. // @match https://test.ourworldoftext.com/*
  10. // @icon https://ourworldoftext.com/static/favicon.png
  11. // @grant none
  12. // @license GNU GPLv3
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. var version = "1.3.0";
  19. // Toolbox title
  20. 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>")
  21. // Colors & rate-limit detection
  22. if(state.worldModel.color_text>0){alert("WARNING\n========================\nColors are disabled on this world")}
  23. /* // Chars per second detection
  24. if(state.worldModel.char_rate[1]<513){
  25. if(state.worldModel.char_rate[1]<100){
  26. alert("WARNING\n========================\nThis world has a very low characters per second value.\nThis heavily affects all scripts.")
  27. } else {
  28. alert("!!!WARNING!!!\n========================\nThis world has a low characters per second value.\nThis affects all scripts.")
  29. }
  30. }
  31. /**/
  32. if(state.worldModel.char_rate[1]>2000){
  33. alert("WARNING\n========================\nThis world has a high rate-limit ("+ state.worldModel.char_rate[0].toString() + " chars per " + state.worldModel.char_rate[1].toString() + "ms" + "). \nScripts will be slow.")
  34. }
  35. // Automatic paste permission bypass.
  36. if(state.worldModel.feature_paste>0){
  37. (function(){Permissions.can_paste = function() {return true;};})();
  38. console.log("No pasting detected - Bypassed");
  39. }
  40. menu.addOption("View rate limit",function(){alert("Rate limit: " + state.worldModel.char_rate[0].toString() + " chars per " + state.worldModel.char_rate[1].toString() + "ms")});
  41. /* Instant Write (previously InstaPaste) v1.1
  42. Supports linebreaks.
  43. */
  44. function instapaste(str,col,loc) {
  45. var scriptloc = loc;
  46. var originalloc = loc;
  47. for(let i=0;i<str.length;i++){
  48. var char = str.charAt(i)
  49. var charsintostring = "-" + i+1
  50. if(char !== "°") {
  51. writeCharTo(char,0x000000,...scriptloc);
  52. scriptloc = coordinateAdd(...scriptloc,0,0,1,0);
  53. } else {
  54. originalloc = coordinateAdd(...originalloc,0,0,0,1)
  55. scriptloc = originalloc;
  56. console.log(originalloc + ", " + loc + ", " + scriptloc)
  57. }
  58. }
  59. }
  60. function aa(){
  61. var kk=prompt("what text to write?\nUse ° for linebreaks :)");
  62. instapaste(kk,0x000000,cursorCoords);
  63. }
  64. menu.addOption("Instant Write",aa)
  65.  
  66. // Fill Script
  67. var fillselection = new RegionSelection();
  68. var fillchar = " ";
  69. var fillcolor = 0x000000;
  70. var fillbcolor = null;
  71. var fillbold = false;
  72. var fillunder = false;
  73. var fillstrike = false;
  74. var fillitalic = false;
  75. var fillbcolorenabled = false;
  76. var filltargetenabled = false;
  77. var filltarget = 0x000000;
  78. // Fill settings modal
  79. // i = input
  80. var fillmodal = new Modal();
  81. fillmodal.createForm();
  82. fillmodal.setFormTitle("Fill settings");
  83. // input values are accessed by [variable].input.value
  84. var ifillchar = fillmodal.addEntry("Fill char (leave empty to use it as a wiper)","text");
  85. var ifillcolor = fillmodal.addEntry("Color","color");
  86. var ifillbcolor = fillmodal.addEntry("Background color (if enabled below)","color");
  87. var ifilltarget = fillmodal.addEntry("Fill target (if enabled below)","color");
  88. fillmodal.createCheckboxField();
  89. // checkbox values are accessed by [variable].elm.firstChild.checked
  90. var ifillbold = fillmodal.addCheckbox("Bold text");
  91. var ifillitalic = fillmodal.addCheckbox("Italic text");
  92. var ifillunder = fillmodal.addCheckbox("Underline text");
  93. var ifillstrike = fillmodal.addCheckbox("Strikethrough text");
  94. var ifillbcolorenabled = fillmodal.addCheckbox("Enable background color");
  95. var ifilltargetenabled = fillmodal.addCheckbox("Enable fill target. If enabled, you can set the fill target to a color and only the chars with that color will get filled. Useful for erasing spam while keeping everything else intact.");
  96. fillmodal.onSubmit(function(){
  97. fillchar = ifillchar.input.value;
  98. filltargetenabled = ifilltargetenabled.elm.firstChild.checked;
  99.  
  100. if(filltargetenabled == true){
  101. filltarget = parseInt(ifilltarget.input.value,16);
  102. };
  103. // 0x must be added so it is treated as a hex value because for some fucking reason the value from the input doesn't have that at the start
  104. if(ifillbcolorenabled.elm.firstChild.checked == true){
  105. fillbcolor = "0x" + ifillbcolor.input.value;
  106. } else {
  107. fillbcolor = null;
  108. };
  109. fillcolor = "0x" + ifillcolor.input.value;
  110. fillbold = ifillbold.elm.firstChild.checked;
  111. fillunder = ifillunder.elm.firstChild.checked;
  112. fillstrike = ifillstrike.elm.firstChild.checked;
  113. fillitalic = ifillitalic.elm.firstChild.checked;
  114. });
  115. // Main fill function
  116. fillselection.tiled = false;
  117. fillselection.onselection(function(coordA, coordB, regWidth, regHeight) {
  118. var charCoord = coordA;
  119. for(let yy = 0; yy < regHeight; yy++) {
  120. for(let xx = 0; xx < regWidth; xx++) {
  121. var charCol = getCharInfo(...charCoord).color;
  122. if(filltargetenabled == true){
  123. if(charCol == parseInt(filltarget,10)){
  124. writeCharTo(fillchar,fillcolor,...charCoord,true,true,fillbcolor,fillbold,fillitalic,fillunder,fillstrike);
  125. }
  126. } else {
  127. writeCharTo(fillchar,fillcolor,...charCoord,true,true,fillbcolor,fillbold,fillitalic,fillunder,fillstrike);
  128. }
  129. charCoord = coordinateAdd(...charCoord,0,0,1,0);
  130. }
  131. charCoord = coordinateAdd(...charCoord,0,0,-regWidth,1);
  132. }
  133. });
  134. w.on("keyDown", function(e) {
  135. if(checkKeyPress(e, "ALT+F")) {
  136. fillselection.startSelection();
  137. }
  138. });
  139. // Menu buttons
  140. menu.addOption("Fill Area\n(ALT+F)",function(){fillselection.startSelection();});
  141. console.log("Check the menu for the fill tool. You can use the shortcut ALT+B to enable it without clicking the menu button.");
  142. menu.addCheckboxOption("Fill Tiles",function(){fillselection.tiled = true;},function(){fillselection.tiled = false;},false);
  143. menu.addOption("Fill Settings",function(){fillmodal.open();});
  144.  
  145. // Stickman Script
  146. // Variable setup
  147. var col = 0x000000;
  148. var col_h = col;
  149. var col_la = col;
  150. var col_ra = col;
  151. var col_ll = col;
  152. var col_rl = col;
  153. var col_body = col;
  154. var loc = [];
  155. // Modals setup
  156. // Limb colors modal
  157. const colormodal2 = new Modal()
  158. colormodal2.createForm()
  159. colormodal2.setFormTitle("Stickman limb colors")
  160. var head = colormodal2.addEntry("Head color","color");
  161. var leftarm = colormodal2.addEntry("Left arm color","color");
  162. var rightarm = colormodal2.addEntry("Right arm color","color");
  163. var body = colormodal2.addEntry("Body color","color");
  164. var leftleg = colormodal2.addEntry("Left leg color","color");
  165. var rightleg = colormodal2.addEntry("Right leg color","color");
  166. colormodal2.onSubmit(function setColors() {
  167. col_h = parseInt(head.input.value,16);
  168. col_la = parseInt(leftarm.input.value,16)
  169. col_ra = parseInt(rightarm.input.value,16)
  170. col_ll = parseInt(leftleg.input.value,16)
  171. col_rl = parseInt(rightleg.input.value,16)
  172. col_body = parseInt(body.input.value,16)
  173. });
  174. // Single color modal
  175. const colormodal = new Modal();
  176. colormodal.createForm();
  177. var stickcolor = colormodal.addEntry("Stickman color","color");
  178. colormodal.setFormTitle("Stickman color. This will override any previously set limb colors.");
  179. colormodal.onSubmit(function setStickCol() {
  180. col = parseInt(stickcolor.input.value,16);
  181. console.log(stickcolor.input.value);
  182. col_h = col;
  183. col_la = col;
  184. col_ra = col;
  185. col_ll = col;
  186. col_rl = col;
  187. col_body = col;
  188. });
  189. col_h = col;
  190. col_la = col;
  191. col_ra = col;
  192. col_ll = col;
  193. col_rl = col;
  194. col_body = col;
  195. // Stickman paster function
  196. function stickman(){
  197. loc = cursorCoords;
  198. writeCharTo("O",col_h,...loc)// Head
  199. loc = coordinateAdd(...loc,0,0,-1,1)
  200. writeCharTo("/",col_la,...loc)// Left arm
  201. loc = coordinateAdd(...loc,0,0,1,0)
  202. writeCharTo("|",col_body,...loc)// Body
  203. loc = coordinateAdd(...loc,0,0,1,0)
  204. writeCharTo('\\',col_ra,...loc)//Right arm
  205. loc = coordinateAdd(...loc,0,0,-2,1)
  206. writeCharTo("/",col_ll,...loc)//Left leg
  207. loc = coordinateAdd(...loc,0,0,2,0)
  208. writeCharTo('\\',col_rl,...loc)//Right leg
  209. console.log(col_h + " " + col_la + " " + col_body + " " + col_ra + " " + col_ll + " " + col_rl);
  210. }
  211. // Menu options to access the modals
  212. menu.addOption("Add Stickman",()=>{stickman()});
  213. menu.addOption("Set Stickman Color",()=>{
  214. colormodal.open()
  215. });
  216. menu.addOption("Set Limb Colors",()=>{
  217. colormodal2.open()
  218. });
  219.  
  220. w.doAnnounce("OWOT Toolbox Loaded - v" + version + " - Enjoy :)");
  221. })();