// ==UserScript==
// @name OWOT Toolbox
// @namespace http://tampermonkey.net/
// @version 2024-10-09
// @description Useful tools for OWOT.
// @author rnd-guy
// @match https://ourworldoftext.com/*
// @match https://test.ourworldoftext.com/*
// @icon https://ourworldoftext.com/static/favicon.png
// @grant none
// @license GNU GPLv3
// ==/UserScript==
(function() {
'use strict';
var version = "1.2.2";
// Toolbox title
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>")
// Colors & rate-limit detection
if(state.worldModel.color_text>0){alert("WARNING\n========================\nColors are disabled on this world.\nThis affects the Stickman Script.")}
/* // Chars per second detection
if(state.worldModel.char_rate[1]<513){
if(state.worldModel.char_rate[1]<100){
alert("WARNING\n========================\nThis world has a very low characters per second value.\nThis heavily affects all scripts.")
} else {
alert("!!!WARNING!!!\n========================\nThis world has a low characters per second value.\nThis affects all scripts.")
}
}
/**/
if(state.worldModel.char_rate[1]>2000){
alert("!!!WARNING!!!\n========================\nThis world has a high rate-limit.\nScripts WILL be slow.")
}
// Automatic paste permission bypass.
if(state.worldModel.feature_paste>0){
(function(){Permissions.can_paste = function() {return true;};})();
console.log("No pasting detected - Bypassed");
}
menu.addOption("View rate limit",function(){alert("Rate limit: " + state.worldModel.char_rate[0].toString() + " chars per " + state.worldModel.char_rate[1].toString() + "ms")});
/* Instant Write (previously InstaPaste) v1.1
Supports linebreaks.
*/
function instapaste(str,col,loc) {
var scriptloc = loc;
var originalloc = loc;
for(let i=0;i<str.length;i++){
var char = str.charAt(i)
var charsintostring = "-" + i+1
if(char !== "°") {
writeCharTo(char,0x000000,...scriptloc);
scriptloc = coordinateAdd(...scriptloc,0,0,1,0);
} else {
originalloc = coordinateAdd(...originalloc,0,0,0,1)
scriptloc = originalloc;
console.log(originalloc + ", " + loc + ", " + scriptloc)
}
}
}
function aa(){
var kk=prompt("what text to write?\nUse ° for linebreaks :)");
instapaste(kk,0x000000,cursorCoords);
}
menu.addOption("Instant Write",aa)
// FILL SCRIPT
var symbl = " "
var timewait = 0;
function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function ccc() {
w.setFlushInterval(0);
var e = [...""];
var r = async (r, t, o, n) => {
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++) {
for (var F = a; F <= c; F++) {
var v = getCharInfoXY(l, F);
if (16777215 !== v.color && 1 !== v.protection) {
writeCharToXY(symbl, charColor, l, F, null, false, false, false, false);
}
if (timewait!==0) {
await wait(timewait); // Wait for 100 milliseconds before continuing
}
}
}
};
menu.addOption("Fill Area", () => {
var e = RegionSelection();
e.init();
e.onselection(r);
e.startSelection();
});
console.log('Check the menu for the "Fill" button');
}
ccc();
menu.addOption("Change Symbol", () => {
symbl = prompt("What symbol to fill with?\n(Leave empty for wiping)");
if (symbl == "") {
symbl = " ";
}
});
menu.addOption("Change Fill Speed", () => {
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");
timewait = timewait.replace(/[^0-9]/g);
if(timewait=="") {
timewait = "0";
}
timewait = parseInt(timewait, 10);
});
// Stickman Script
// Variable setup
var col = 0x000000;
var col_h = col;
var col_la = col;
var col_ra = col;
var col_ll = col;
var col_rl = col;
var col_body = col;
var loc = [];
// Modals setup
// Limb colors modal
const colormodal2 = new Modal()
colormodal2.createForm()
colormodal2.setFormTitle("Stickman limb colors")
var head = colormodal2.addEntry("Head color","color");
var leftarm = colormodal2.addEntry("Left arm color","color");
var rightarm = colormodal2.addEntry("Right arm color","color");
var body = colormodal2.addEntry("Body color","color");
var leftleg = colormodal2.addEntry("Left leg color","color");
var rightleg = colormodal2.addEntry("Right leg color","color");
colormodal2.onSubmit(function setColors() {
col_h = parseInt(head.input.value,16);
col_la = parseInt(leftarm.input.value,16)
col_ra = parseInt(rightarm.input.value,16)
col_ll = parseInt(leftleg.input.value,16)
col_rl = parseInt(rightleg.input.value,16)
col_body = parseInt(body.input.value,16)
});
// Single color modal
const colormodal = new Modal();
colormodal.createForm();
var stickcolor = colormodal.addEntry("Stickman color","color");
colormodal.setFormTitle("Stickman color. This will override any previously set limb colors.");
colormodal.onSubmit(function setStickCol() {
col = parseInt(stickcolor.input.value,16);
console.log(stickcolor.input.value);
col_h = col;
col_la = col;
col_ra = col;
col_ll = col;
col_rl = col;
col_body = col;
});
col_h = col;
col_la = col;
col_ra = col;
col_ll = col;
col_rl = col;
col_body = col;
// Stickman paster function
function stickman(){
loc = cursorCoords;
writeCharTo("O",col_h,...loc)// Head
loc = coordinateAdd(...loc,0,0,-1,1)
writeCharTo("/",col_la,...loc)// Left arm
loc = coordinateAdd(...loc,0,0,1,0)
writeCharTo("|",col_body,...loc)// Body
loc = coordinateAdd(...loc,0,0,1,0)
writeCharTo('\\',col_ra,...loc)//Right arm
loc = coordinateAdd(...loc,0,0,-2,1)
writeCharTo("/",col_ll,...loc)//Left leg
loc = coordinateAdd(...loc,0,0,2,0)
writeCharTo('\\',col_rl,...loc)//Right leg
console.log(col_h + " " + col_la + " " + col_body + " " + col_ra + " " + col_ll + " " + col_rl);
}
// Menu options to access the modals
menu.addOption("Add Stickman",()=>{stickman()});
menu.addOption("Set Stickman Color",()=>{
colormodal.open()
});
menu.addOption("Set Limb Colors",()=>{
colormodal2.open()
});
w.doAnnounce("OWOT Toolbox Loaded - v" + version + " - Enjoy :)");
})();