Greasy Fork 支持简体中文。

OWOT Toolbox

Useful tools for OWOT.

目前為 2025-02-26 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name OWOT Toolbox
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-02-25
  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. // Fill settings modal
  77. // i = input
  78. var fillmodal = new Modal();
  79. fillmodal.createForm();
  80. fillmodal.setFormTitle("Fill settings");
  81. // input values are accessed by [variable].input.value
  82. var ifillchar = fillmodal.addEntry("Fill char (leave empty to use it as a wiper)","text","required");
  83. var ifillcolor = fillmodal.addEntry("Color","color");
  84. var ifillbcolor = fillmodal.addEntry("Background color (if enabled below)","color");
  85. fillmodal.createCheckboxField();
  86. // checkbox values are accessed by [variable].elm.firstChild.checked
  87. var ifillbold = fillmodal.addCheckbox("Bold text");
  88. var ifillitalic = fillmodal.addCheckbox("Italic text");
  89. var ifillunder = fillmodal.addCheckbox("Underline text");
  90. var ifillstrike = fillmodal.addCheckbox("Strikethrough text");
  91. var ifillbcolorenabled = fillmodal.addCheckbox("Enable background color");
  92. fillmodal.onSubmit(function(){
  93. if(ifillchar.input.value !== "") {
  94. fillchar = ifillchar.input.value;
  95. };
  96. // 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
  97. if(ifillbcolorenabled.elm.firstChild.checked == true){
  98. fillbcolor = "0x" + ifillbcolor.input.value;
  99. };
  100. fillcolor = "0x" + ifillcolor.input.value
  101. fillbold = ifillbold.elm.firstChild.checked;
  102. fillunder = ifillunder.elm.firstChild.checked;
  103. fillstrike = ifillstrike.elm.firstChild.checked;
  104. fillitalic = ifillitalic.elm.firstChild.checked;
  105. });
  106. // Main fill function
  107. fillselection.tiled = false;
  108. fillselection.onselection(function(coordA, coordB, regWidth, regHeight) {
  109. var charCoord = coordA;
  110. for(let yy = 0; yy < regHeight; yy++) {
  111. for(let xx = 0; xx < regWidth; xx++) {
  112. writeCharTo(fillchar,fillcolor,...charCoord,true,true,fillbcolor,fillbold,fillitalic,fillunder,fillstrike);
  113. charCoord = coordinateAdd(...charCoord,0,0,1,0);
  114. }
  115. charCoord = coordinateAdd(...charCoord,0,0,-regWidth,1);
  116. }
  117. });
  118. w.on("keyDown", function(e) {
  119. if(checkKeyPress(e, "ALT+B")) {
  120. fillselection.startSelection();
  121. }
  122. });
  123. // Menu buttons
  124. menu.addOption("Fill Area\n(ALT+B)",function(){fillselection.startSelection();});
  125. console.log("Check the menu for the fill tool. You can use the shortcut ALT+B to enable it without clicking the menu button.");
  126. menu.addCheckboxOption("Fill Tiles",function(){fillselection.tiled = true;},function(){fillselection.tiled = false;},false);
  127. menu.addOption("Fill Settings",function(){fillmodal.open();});
  128.  
  129. // Stickman Script
  130. // Variable setup
  131. var col = 0x000000;
  132. var col_h = col;
  133. var col_la = col;
  134. var col_ra = col;
  135. var col_ll = col;
  136. var col_rl = col;
  137. var col_body = col;
  138. var loc = [];
  139. // Modals setup
  140. // Limb colors modal
  141. const colormodal2 = new Modal()
  142. colormodal2.createForm()
  143. colormodal2.setFormTitle("Stickman limb colors")
  144. var head = colormodal2.addEntry("Head color","color");
  145. var leftarm = colormodal2.addEntry("Left arm color","color");
  146. var rightarm = colormodal2.addEntry("Right arm color","color");
  147. var body = colormodal2.addEntry("Body color","color");
  148. var leftleg = colormodal2.addEntry("Left leg color","color");
  149. var rightleg = colormodal2.addEntry("Right leg color","color");
  150. colormodal2.onSubmit(function setColors() {
  151. col_h = parseInt(head.input.value,16);
  152. col_la = parseInt(leftarm.input.value,16)
  153. col_ra = parseInt(rightarm.input.value,16)
  154. col_ll = parseInt(leftleg.input.value,16)
  155. col_rl = parseInt(rightleg.input.value,16)
  156. col_body = parseInt(body.input.value,16)
  157. });
  158. // Single color modal
  159. const colormodal = new Modal();
  160. colormodal.createForm();
  161. var stickcolor = colormodal.addEntry("Stickman color","color");
  162. colormodal.setFormTitle("Stickman color. This will override any previously set limb colors.");
  163. colormodal.onSubmit(function setStickCol() {
  164. col = parseInt(stickcolor.input.value,16);
  165. console.log(stickcolor.input.value);
  166. col_h = col;
  167. col_la = col;
  168. col_ra = col;
  169. col_ll = col;
  170. col_rl = col;
  171. col_body = col;
  172. });
  173. col_h = col;
  174. col_la = col;
  175. col_ra = col;
  176. col_ll = col;
  177. col_rl = col;
  178. col_body = col;
  179. // Stickman paster function
  180. function stickman(){
  181. loc = cursorCoords;
  182. writeCharTo("O",col_h,...loc)// Head
  183. loc = coordinateAdd(...loc,0,0,-1,1)
  184. writeCharTo("/",col_la,...loc)// Left arm
  185. loc = coordinateAdd(...loc,0,0,1,0)
  186. writeCharTo("|",col_body,...loc)// Body
  187. loc = coordinateAdd(...loc,0,0,1,0)
  188. writeCharTo('\\',col_ra,...loc)//Right arm
  189. loc = coordinateAdd(...loc,0,0,-2,1)
  190. writeCharTo("/",col_ll,...loc)//Left leg
  191. loc = coordinateAdd(...loc,0,0,2,0)
  192. writeCharTo('\\',col_rl,...loc)//Right leg
  193. console.log(col_h + " " + col_la + " " + col_body + " " + col_ra + " " + col_ll + " " + col_rl);
  194. }
  195. // Menu options to access the modals
  196. menu.addOption("Add Stickman",()=>{stickman()});
  197. menu.addOption("Set Stickman Color",()=>{
  198. colormodal.open()
  199. });
  200. menu.addOption("Set Limb Colors",()=>{
  201. colormodal2.open()
  202. });
  203.  
  204. w.doAnnounce("OWOT Toolbox Loaded - v" + version + " - Enjoy :)");
  205. })();