roostdocs

Functions

Functions work in conditions and values: if count($tabs) > 3, set n = round($x, 2). The time, browser and page functions work in Roost Script too, under the names in the last column; for the rest, Roost Script uses JavaScript's own methods (list.length, text.toLowerCase(), Math.round()).

Lists and text

Roost BasicDoesRoost Script
count()how many items (or letters)JavaScript’s own
len()same as countJavaScript’s own
empty()true if there’s nothingJavaScript’s own
first()the first itemJavaScript’s own
last()the last itemJavaScript’s own
join()a list as text: join($tabs, " / ")JavaScript’s own
split()text into a listJavaScript’s own
contains()contains(text or list, "words")JavaScript’s own
startswith()startswith(text, "start")JavaScript’s own
endswith()endswith(text, "end")JavaScript’s own
lower()lowercase textJavaScript’s own
upper()uppercase textJavaScript’s own
trim()text without spaces around itJavaScript’s own
replace()replace(text, "old", "new")JavaScript’s own
text()anything as textJavaScript’s own
number()the first number in some textJavaScript’s own

Numbers

Roost BasicDoesRoost Script
round()round(3.14159, 2)Math.roundTo()
floor()round downMath.floor()
ceil()round upMath.ceil()
abs()abs(-3) is 3Math.abs()
sqrt()square rootMath.sqrt()
pow()pow(2, 10) is 1024Math.pow()
min()the smallest numberMath.min()
max()the largest numberMath.max()
sum()sum($prices): all the numbers added upMath.sum()
avg()the averageMath.avg()
median()the middle numberMath.median()
stdev()how spread out the numbers are (standard deviation)Math.stdev()
clamp()clamp(x, 1, 10): x, kept between 1 and 10Math.clamp()
percent()percent(3, 12) is 25Math.percent()
format()format(1234.5) is "1,234.50"; format(x, 0) for no decimalsMath.format()
gcd()greatest common divisorMath.gcd()
lcm()least common multipleMath.lcm()
isprime()whether a whole number is primeMath.isPrime()
random()random(1, 6): a whole number between themMath.randomInt()
range()range(1, 5): 1, 2, 3, 4, 5JavaScript’s own

Hashes

Checksums as hex text, for checking text against a published checksum or noticing when something changed. md5 and sha1 are fine for that, not for secrets. The hash command does the same for piped lines: page --css "#terms" | hash.

Roost BasicDoesRoost Script
md5()md5 hash (hex) of some textmd5()
sha1()sha1 hash (hex)sha1()
sha256()sha256 hash (hex)sha256()
sha512()sha512 hash (hex)sha512()
hash()hash(text, "sha384"): md5, sha1, sha256, sha384 or sha512hash()

Time

Roost BasicDoesRoost Script
hour()the hour now (0–23)hour()
minute()the minute nowminute()
weekday()monday … sundayweekday()
today()the date, like 2026-11-11today()
now()the time, like 09:30now()

The browser

Roost BasicDoesRoost Script
title()the title of the tab you’re ontitle()
url()the address of the tab you’re onurl()
tabcount()how many tabs are opentabCount()
site()the site of an address or tabsite()

Page checks

These read the tab you're on, so a script can look before it acts: if exists("Accept all"). They see what's on the screen, and only text: they can't change the page.

Roost BasicDoesRoost Script
has()whether the page shows some text: has("Sold out")has()
exists()whether there’s a button or link with that text: exists("Next page")exists()
read()the text of the first thing matching a CSS selector: read("h1")read()
readall()the text of everything matching a CSS selector, as a list: readall(".price")readAll()
value()what a field on the page holds: value("Email")value()
Roost Basic
if has("Sold out")
  notify "Still sold out"
else if exists("Add to cart")
  click "Add to cart"
end
set prices = readall(".price")
print "First price: $(first($prices))"