Reference
window.landmark
Your element's HTML, CSS and JS run inside a sandboxed iframe (sandbox="allow-scripts" only, with no parent access and no cookies). The window.landmark object is your bridge to the stream: the event that fired it, the live event feed, your settings, saved values, text to speech, translation and sound. Standard browser features (DOM, Canvas, requestAnimationFrame, timers, and images, fonts and audio by URL) all work. The iframe has a null origin, so there is no Landmark endpoint to call. fetch and XMLHttpRequest have nothing to talk to, and the AI assistant refuses to write them. localStorage, sessionStorage and cookies are unavailable too. Everything your element needs arrives as an event or through landmark.data (your real menu), and anything it must remember goes in landmark.vars.
Runtime contract version 5. To learn how elements are made, placed, shared and used on their own, see Elements & overlays.
At a glance
window.landmark = {
event: { platform, type, usd_amount, payload, occurred_at }, // what fired an alert
mode: "alert" | "persistent", // one-shot pop-up or long-lived widget
preview: boolean, // true in the editor preview (no sound, no billing)
config: { ...settings }, // your _schema settings, keyed by id
events: [ ...received ], // events since this page loaded, newest first, up to 200
emotes: { code: imageUrl }, // the streamer's custom chat emotes
on(type, cb) => unsubscribe, // listen to the live feed
vars: { get(key) => Promise, set(key, value) => Promise }, // saved values for this element
globals: { get(key) => Promise, set(key, value) => Promise }, // saved values shared by the account
tts(text, opts?), // speak text on the live overlay
translate(text, lang) => Promise, // { text, translated, detected }
sound: { url, volume, play(url?, volume?) }, // the editor's Sound section
onClearChat(cb) => unsubscribe, // register a "clear what you drew" handler
clearChat(), // run those handlers
dismiss(), // close an alert early
data: { kinds, get(kind) => Promise, watch(kind, cb) => unsubscribe } // your real menu
}Properties
landmark.event- The event that mounted this element (read only). Shape:
{ platform, type, usd_amount, payload, occurred_at }. For a persistent element this is a fixed placeholder ({ platform: "", type: "", payload: {} }) that never changes, even after events arrive. Uselandmark.on()there. See event payloads for the fields insidepayload. landmark.mode"alert" | "persistent""alert"is a one-shot pop-up that closes after itsduration_ms."persistent"is a long-lived widget (chat box, leaderboard, goal bar, always-on wheel) that mounts once and reacts to the live feed. Branch on it if your element supports both.landmark.previewbooleantruein the editor and hub preview,falseon the live OBS overlay. The preview silences audio (so a grid of previews stays quiet) and makeslandmark.tts()do nothing (so previews never bill). The runtime already handles sound and TTS for you, so you rarely need to read it.landmark.configRecord<string, unknown>- The values of your
_schemasettings, keyed by setting id, so a streamer can tune your element without touching code. See Settings for every control type, the list control included. Goals, counters and timers also get_eid, the id the server uses to address them. Always guard:const c = landmark.config || ; landmark.eventsArray<Event>- The events this page has received so far, newest first, up to 200. It is empty when your script first runs, because events arrive after the script starts, and it starts empty again on every OBS reload. Use it to look back over what arrived since the page loaded. It cannot restore history, so keep totals in
landmark.vars. Each entry has the same shape as the callback inlandmark.on(). landmark.emotesRecord<string, string>- The streamer's installed custom chat emotes, as code to image URL. It arrives shortly after the element loads and refreshes live, so read it for each message. It holds no platform emotes. Those arrive per message in
payload.fragments. Handle the fragments first, then match leftover text against this map. Writelandmark.emotesliterally in your code: the overlay only sends the map to elements that mention it. Emotes can be animated and wide, so size them by one side and let the other follow.
Methods
landmark.on(type, cb)→() => void- Listen to the live event feed.
typeis any type in the event index below, or"*"for all of them. The callback gets one event{ platform, type, usd_amount, payload, occurred_at }. It returns a function that stops listening. This is what makes a chat box, a live leaderboard or an always-on wheel possible.const off = landmark.on("cheer", (e) => { spawnConfetti(e.payload.amount); // bits if ((e.usd_amount || 0) >= 5) landmark.tts(e.payload.user + " cheered big!"); }); // later: off() landmark.vars.get(key)→Promise<value | null>landmark.vars.set(key, value)→Promise<true>- Saved JSON values for this element: counters, leaderboards, anything that should survive between fires and OBS reloads. Values must be JSON. On the live overlay they are saved on your account. In the editor preview they are held in memory, and the editor's Variables panel can seed them so a preview shows real-looking numbers.
const n = ((await landmark.vars.get("count")) || 0) + 1; await landmark.vars.set("count", n); landmark.globals.get(key)→Promise<value | null>landmark.globals.set(key, value)→Promise<true>- Like
vars, but shared by your whole account: every element and the chatbot read and write the same keys. Goals, counters and timers can publish their value to a global (the "Publish value for other elements" option), and a chatbot command can set one (the "set a variable" action on the Chatbot page) so chat drives your visuals. Each get reads fresh, so read on events, not every frame. Elements can also react the moment a command fires:// A chatbot command set to "send an overlay event" arrives as: landmark.on("command", (ev) => { if (ev.payload.name !== "hype") return; // !hype burst(ev.payload.user, ev.payload.args); }); landmark.tts(text, opts?)- Read
textaloud through your TTS.opts.voiceis optional. On the live overlay it queues a read on your account, spoken and billed through your normal TTS. An AI voice is Landmark Usage, a standard voice is free. In the editor preview it does nothing, so previews never bill. Empty text is ignored. Use it for moments worth speaking (goal reached, a big tip), never for every chat line.landmark.tts("We just hit the goal!", { voice: "Brian" }); landmark.translate(text, lang)→Promise<{ text, translated, detected }>- Translate
textinto the language codelangwith Landmark's shared translator. The promise always resolves. When the translator cannot answer, or in the editor preview, it resolves to the original text withtranslated: false, so a chat element simply shows the original line.const r = await landmark.translate("hola", "en"); line.textContent = r.text; // "hello", or "hola" when it could not translate landmark.sound{ url, volume, play(url?, volume?) }- The sound picked in the editor's Sound section.
urlisnullwhen none is set.play()plays it at its volume, andplay(otherUrl, volume)plays any other URL. It is silent in the editor preview. The editor's Test fire is how you hear it. landmark.onClearChat(cb)→() => voidlandmark.clearChat()- A chat element registers a handler with
onClearChat, andclearChat()runs every handler, for example from a Skill that wipes the box. It only clears what this element drew. Nothing is deleted on the platform. landmark.dismiss()- Close an alert before its
duration_msruns out. Do not call it from a persistent element. landmark.redeems{ on(key, cb), available(key, open, { viewers, reason }), list() }- What viewers redeem in your element. Declare each one in the element's properties as
_redeems. Saving the element puts it on your menu, at its price in coins, and the price you set on the Menu stays. Viewers redeem it like any other Skill. Use this for anything viewers pay to make happen in the element. A payment amount or a reward name is not a way to start it.// In the element's properties: // "_redeems": [{ "key": "boost", "label": "Marble boost", "coins": 50 }] // Runs on every paid redemption. landmark.redeems.on("boost", function (r) { // r = { key, label, user, user_login, text, coins, test, platform, viewer } speedUp(r.viewer); }); // Only the racers can boost, and only while a race runs. landmark.redeems.available("boost", racing, { viewers: racers.map(function (x) { return x.joinEvent; }), reason: racing ? "Only for racers in this race" : "Opens when a race starts" });availablesets who can redeem it right now.viewersare events fromlandmark.onor{ platform, user_id, user_login }, matched through accounts viewers linked, and left out for everyone.reasonis the short line everyone else sees. Landmark refuses a Skill the element did not open, and the viewer is not charged. A Skill you only listen to is open to everyone while the element runs in OBS, and closed while it does not.r.vieweris the entry it matched:{ p, id, l }(platform, user id, login).list()resolves to[{ key, label, coins, on }].
Settings (_schema)
_schema in the element's properties is a list of settings. The editor shows one control per entry under Style, grouped under small headings by group, and your code reads each value as landmark.config[id]. Placing the element on an overlay can override any value for that one placement.
{ id, label, type, default, min?, max?, step?, options?, group?, placeholder?, item? }
// key is accepted in place of idcolor·number·slider·text·toggle- One value each.
sliderandnumbertakemin,maxandstep. A long text default gets a larger text box. selectoptionsis a list of{ value, label }objects, and the default is one of the values.platforms- A pick of the platforms to count. The value is an array of platform ids, default
[](all). location- A place picker in the editor, for elements like weather.
list- Rows the streamer can add, remove and drag into order, for milestone ladders, prize lists and anything repeatable.
itemnames the fields of one row, each{ key, label, type }withtypeone oftext,number,colorortoggle. The value is an array of row objects keyed by those keys, in the order the streamer set.maxcaps the rows (at most 100). Use a list for anything repeatable, never one text setting split on commas. Older elements that keep a list in a text setting keep working.
// In the element's properties
"_schema": [
{
"id": "milestones",
"type": "list",
"label": "Milestones",
"group": "Goal",
"max": 20,
"item": [
{ "key": "amount", "label": "Amount", "type": "number" },
{ "key": "title", "label": "What happens", "type": "text" },
{ "key": "color", "label": "Color", "type": "color" }
],
"default": [
{ "amount": 50, "title": "Wear the hat", "color": "#22c55e" },
{ "amount": 100, "title": "Spicy noodles", "color": "#f97316" }
]
}
]Live events
Every callback from landmark.on(), and every entry in landmark.events, is one event:
{
platform: "twitch" | "google" | "kick" | "rumble" | "tiktok" |
"landmark" | "portal" | "game:<slug>",
type: see the event index below,
usd_amount: number | null, // US dollars for money events, null otherwise
occurred_at: "2026-06-25T12:00:00Z",
payload: { ... } // depends on the type
}platform is "google" for YouTube, "landmark" for Landmark itself (a cash tip, a referral join, a chatbot command) and "portal" for a coin tip or a portal Skill. Always guard for missing fields. Payloads vary by platform (a Twitch cheer has bits, a TikTok gift has diamonds). Fields marked with ? only come from some platforms.
Event index
Every type landmark.on() accepts. "Live" types reach any element on any source. The rest only arrive while their built-in element is placed on the same overlay (see status feeds).
| Type | Platforms | Payload fields | Dollars | Arrives |
|---|---|---|---|---|
chat | twitch, google, kick, rumble, tiktok | user, user_login?, avatar?, color?, text, fragments?, badges?, orientation? | no | Live |
follow | twitch, google, kick, rumble, tiktok | user, user_login?, avatar? | no | Live |
subscribe | twitch, google, kick, rumble, tiktok | user, user_login?, avatar?, tier?, months?, member?, uniqueId?, userId? | yes | Live |
gift | twitch, google, kick, tiktok | user, avatar?, gift_name?, amount?, total?, kind?, gift? | yes | Live |
cheer | twitch | user, user_login?, avatar?, amount (bits), powerup? | yes | Live |
superchat | google, rumble, landmark | user, avatar?, text, amount? | yes | Live |
raid | twitch | user, amount (viewers) | no | Live |
redemption | twitch, kick, portal | user, reward, cost? | no | Live |
tip | portal | user, amount ("500 coins" string), amount_cents (the coin count), text, source, from_wallet | yes | Live |
viewers | twitch, google, kick, rumble, tiktok | viewerCount, streamId?, totalUser? | no | Live |
like | tiktok, google, rumble | user?, uniqueId?, userId?, avatar?, likeCount, totalLikes?, totalLikeCount? | no | Live |
share | tiktok | user, uniqueId?, userId?, avatar? | no | Live |
comment | user, text, source | no | Live | |
stream_online | twitch | stream_id, kind | no | Live |
stream_offline | twitch | none | no | Live |
landmark_join | landmark | user | no | Live |
command | landmark | name, user, args (string[]), text | no | Live |
camera_filter | landmark | user, filter_id, filter_name, emoji, kind, source, amount?, test? | yes | Live |
caption | landmark | text, final | no | Live |
irl | landmark | at, lat?, lon?, acc?, speed?, heading?, dist_m?, steps?, kcal?, off? | no | Live |
control | landmark | target, verb, num?, value?, target_delta?, anchor?, paused?, frozen?, server_now? | no | Live |
chat.purge | landmark | scope, messageId?, platform?, user? | no | Live |
sound_played | landmark, twitch, google, kick, rumble, tiktok | url, volume?, viewer?, label? | yes | Live |
chest_fund | landmark | coins, tier | no | Live |
chest_open | landmark | total, winners ({ name, coins }[]), count, eligible, opened_by, chest_id | no | Live |
chest_win | landmark | user, coins, text | no | Live |
game_action | game:<slug> | (whatever the mod sent) | no | Live |
game_challenge_complete | game:<slug> | user, text, completions? | no | Live |
game_challenge_reset | game:<slug> | user, text | no | Live |
game_fish_scored | game:<slug> | user, text | no | Live |
game_fish_mode | game:<slug> | user, text | no | Live |
camera | landmark | active_prompt, viewer, seconds_left, queued, capture_live, next_prompt, next_viewer, filters_active?, filters_queued?, rate_cents_per_sec? | no | Needs Landmark Camera status placed |
profit | landmark | revenue_cents, cost_cents, net_cents | no | Needs Profit placed |
schedule | landmark | items | no | Needs Schedule placed |
redeems | landmark | redeems, currency | no | Needs Skills menu placed |
poll | landmark | poll | no | Needs Poll placed |
giveaway | landmark | giveaway | no | Needs Giveaway placed |
minewithme | landmark | state | no | Needs Mine With Me placed |
tts_reading | landmark | source_event_id | no | Needs Chat box placed |
media_share | landmark | playing, queue_len, up_next?, action?, viewer?, media_platform?, title?, test? | yes | Needs Media share placed |
chat
payload.userstring- Display name of the chatter.
payload.textstring- The message text.
payload.user_id·user_loginstring?- Platform user id and login when available. Twitch sends both, YouTube and Kick send
user_id, TikTok sendsuserIdanduniqueId. payload.avatar·payload.colorstring?- The chatter's picture and name color, when the platform sends them.
payload.badgesArray<{ type, img? }>?- Role badges.
typeis one ofbroadcaster,owner,mod,lead_mod,vip,sub,member.imgis the real badge image when the platform sent one. Left out when there are no badges. payload.fragmentsArray<{ type, text, id?, url?, gif? }>?- Only present when the message has emotes.
typeis"text"or"emote". An emote fragment carries anidor a readyurl. A Twitch chat GIF is anemotefragment withgif: trueand itsurl(show it larger than an emote). When absent, usetext. payload.is_mod·is_ownerboolean?- YouTube flags (other platforms carry the same facts in badges).
After a page load the overlay replays up to the last 60 chat lines into on("chat"), so a chat box refills on its own.
follow
payload.userstring·payload.user_idstring?- Who followed. No
usd_amount.
subscribe
payload.userstring- Who subscribed or became a member.
payload.tierstring?- Twitch tier (
"1000","2000","3000") or the YouTube member level name. payload.memberbooleantruefor a YouTube membership,falsefor a paid Twitch, Kick or Rumble sub.payload.months·payload.streak·payload.milestonenumber?- Months so far, the streak, and the YouTube milestone month, on resubs and milestones.
payload.textstring?- The resub or milestone message, when shared.
usd_amountnumber- What the streamer earns (Twitch Tier 1 about $2.50, Tier 2 $5.00, Tier 3 $12.50, a YouTube member, Kick or Rumble sub $4.99).
cheer (Twitch bits)
payload.userstring·payload.amountnumber- Who cheered and how many bits.
payload.textstring?- The cheer message.
payload.anonymousbooleantruefor an anonymous cheer.payload.bit_image·payload.bit_tierstring? / number?- The cheermote image and its tier, when known.
usd_amountnumber- bits × $0.01.
superchat (YouTube Super Chats and Stickers, Rumble rants, Landmark cash tips)
On platform "landmark" a superchat is a Landmark cash tip. See tips below. Check e.platform when the difference matters.
payload.userstring- Who paid.
payload.amountstring- The amount as shown, for example
"$5.00","CA$10.00"or"₹1,000.00".usd_amountis the number. payload.textstring?- The message (absent on Super Stickers).
payload.currency·payload.tierstring? / number?- Currency code and the YouTube Super Chat tier, when known.
payload.stickertrue?- Present on a Super Sticker.
usd_amountnumber- Converted to US dollars at live rates.
gift (gift subs, sub bombs, TikTok and Kick gifts)
payload.userstring- The gifter (
"Anonymous"for anonymous Twitch bombs). payload.kind"subscription" | "item""subscription"for gifted subs and memberships,"item"for a TikTok or Kick gift.payload.total·payload.communitynumber? / boolean?- How many subs were gifted, and whether it was a community bomb.
payload.tier·payload.anonymousstring? / boolean?- Sub tier, and whether the bomb was anonymous (Twitch).
payload.giftName·diamonds·totalDiamonds·repeat(TikTok)- Gift name, diamonds per gift, combo total and final combo count (50 roses fire one event).
payload.gift{ id, name, iconUrl, cost }?- Gift picture and cost for TikTok and Kick gifts, when known.
usd_amountnumber- Gift value in US dollars.
raid (Twitch)
payload.userstring·payload.amountnumber- The raiding channel and how many viewers it brought. No
usd_amount.
redemption (channel points and Landmark Skills)
payload.user·payload.rewardstring- Who redeemed and the reward name.
payload.input·payload.textstring | null- What the viewer typed, when the reward asks for it.
payload.reward_id·payload.slug·payload.surfacestring?- The Twitch or Kick reward id, and the Landmark Skill slug and surface, so you can target one Skill across renames. To show it, that is all you need. For something viewers pay to make happen in your element, use
landmark.redeems. payload.cost·payload.statusnumber? / string?- Channel point cost and status (Twitch).
like · share · viewers · comment
like(TikTok, YouTube, Rumble)payload.likeCountis the new likes. TikTok addspayload.userandpayload.totalLikes. YouTube and Rumble addpayload.totalLikeCountand have no user.share(TikTok)payload.user, plusuniqueIdanduserId.viewers(all platforms)payload.viewerCount, refreshed every few minutes. Treat it as approximate.comment(YouTube)payload.user,payload.text. A video comment, not live chat.
tips (Landmark cash and coin tips)
Landmark tips reach your element as two different events. An element that reacts to tips has to handle both.
- Cash tip:
type "superchat"on platform"landmark" payload.user,payload.amountas a string such as"$5.00",payload.textandpayload.source("tip-page").usd_amountis the dollars.- Coin tip:
type "tip"on platform"portal" payload.user,payload.amountas a string such as"500 coins",payload.amount_cents(the coin count),payload.textandpayload.from_wallet.usd_amountis the coins at one cent each.
function addTip(e) { /* e.usd_amount is the dollar value either way */ }
landmark.on("tip", addTip); // coin tips
landmark.on("superchat", (e) => { // cash tips
if (e.platform === "landmark") addTip(e); // skip YouTube Super Chats and Rumble rants
});A tip alert has two triggers for the same reason: one for platform Landmark with the event superchat, one for platform Portal with the event tip. The editor's trigger list and the AI assistant set up the pair for you.
Landmark events
command· platformlandmarkpayload.name,user,args(string array),text. A chatbot command set to send an overlay event.camera_filterpayload.user,filter_id,filter_name,emoji,kind,source,amount,test. A viewer applied an AR camera filter.captionpayload.textandpayload.final. A live caption line.final: trueis a finished sentence.irlpayload.at, and while sharing:lat,lon,acc,speed(metres per second),heading,dist_m,steps,kcal.off: truemeans the phone stopped sharing. Only element sources get it.controlpayload.target(yourlandmark.config._eid),verb(add,sub,set,reset,enabled) and the new state:valueandtarget_deltafor goals and counters,anchor,paused,frozen,server_nowfor timers.chat.purgepayload.scope(messageoruser),messageId,platform,user. A mod removed a message or banned a user.sound_playedpayload.url,volume,viewer,label. A soundboard sound played. Landmark plays the audio, your element only shows a card.landmark_joinpayload.user. Someone joined Landmark through your referral link.stream_online·stream_offline(Twitch)payload.stream_idandpayload.kindwhen the stream starts, nothing when it ends.chest_fund·chest_open·chest_win- The Community Chest.
chest_fundhascoinsandtier.chest_openhastotal,winners({ name, coins }each),count,eligible,opened_by,chest_id.chest_winis one winner:user,coins,text. game_action,game_challenge_complete,game_challenge_reset,game_fish_scored,game_fish_mode· platformgame:<slug>- From a game mod.
game_actioncarries whatever the mod sent. The named milestones also carryuserandtext.
Status feeds that need a built-in element
A few events are not part of the live feed. The overlay page asks Landmark for them on a timer and pushes the answer into your element, and it only does that while the matching built-in element is placed on the same overlay. A custom element on its own browser source, or on an overlay without that built-in, never gets them, in OBS or in the editor preview.
camera: Landmark Camera status, every 3 seconds. Needs the Landmark Camera status element.media_sharenow-playing status, every 3 seconds. Needs the Media share element. The queue actions (queued,started,finished,rejected) arrive without it.tts_reading: the chat line being read aloud. Runs while a chat element has its highlight option on.profit,schedule,redeems,poll,giveaway,minewithme: each belongs to its built-in element, and their shapes can change. Add the built-in instead of rebuilding it.pollandgiveawayalso arrive on the live feed when they change, as the bare snapshot, but there is no first snapshot without the built-in.
Goals, counters and timers
A goal bar, counter or timer is a meter. Give the element that kind, set display_only: true in its properties, and the server counts every event, runs chat commands, the dock and rules, and pushes the result to your code. Your code never counts and never writes the value.
- Read the starting value on mount with
landmark.vars.get:progressandtarget_deltafor a goal,valuefor a counter,anchor,paused,frozenand_server_nowfor a timer (epoch seconds). - Apply
controlevents whosepayload.targetequalslandmark.config._eid. - A goal declares settings with the ids
goal,titleandmetric. Milestones belong in a list setting. - Progress is kept per placement, so the editor's Variables panel stays hidden for a meter. Use the Current total section or the Goals page to set it.
Your menu and other account data
landmark.data.get(kind) reads data you already show in public, for the account the overlay belongs to. The page around the element does the read, so the element still never touches the network. It always resolves: the data, or null when it is not available (unknown kind, a signed-out preview, an error, or no answer within 10 seconds). landmark.data.kinds lists the kinds. Nothing here carries a wallet, an email, a viewer account id, a Skill id or a cash balance, and nothing here can fire a Skill.
landmark.data.watch(kind, cb, everyMs) calls cb with the first answer and again whenever it changes. It reads again every 15 seconds by default and never faster than every 5. It returns a function that stops watching. Use it for anything that should follow your menu: a new price, an item switched off, stock running out, the stream going live.
"redeems" is your real menu, the same one viewers see on your page, in the same order. It works the same on the live overlay, in the editor preview, on its own as a browser source, and on the phone and desktop apps. Items you paused or hid are never in it. Each item says whether a viewer can redeem it right now, so a menu element can show what is on offer and dim the rest while you are offline.
"owed" is your custom Skills, the ones you do by hand, with how many are left and who you still owe one, in the order they came in. Someone who redeemed it twice is one row with a count of 2. Marking one done on your Menu or in the dock takes it off the list.
| Kind | Shape | What it is |
|---|---|---|
redeems | { live, count, groups: string[], redeems: { label, description, kind, group, icon, image_url, color, coins, usd, price_text, unit, available, note, stock_left, stock_total, sold_out }[] } | the streamer's real menu: everything a viewer can redeem on Landmark, in the portal's order (grouped, cheapest first inside a group). live is whether the stream is live. count is how many can be redeemed this second. groups is the group names in order ("Custom", "On stream", "Camera", "Media and voice", "Games", "Lights and plugs", "Other"), and group on each item is the one it sits in. icon is an emoji, image_url a picture or null. coins is the coin price (1 coin = 1 cent) and usd the same price in dollars, null when it has no Landmark price. price_text is the price the way the menu says it ("100 coins or $1", "5 coins a second"), null when there is none. unit is "per second" or null. available is true when a viewer can redeem it right now (live, the game running, the overlay or Desktop open), and note says when it can be when it cannot ("when live"). stock_left and stock_total are numbers on a Skill with limited stock ("12 left", "12 of 20 left") and null when it has no limit. sold_out is true when the stock ran out, and available is then false. Items the streamer paused or hid are never in it |
owed | { items: { label, coins, stock_left, stock_total, sold_out, paused, owed_total, owed: { name, count, since }[] }[] } | the streamer's custom Skills (the ones done by hand, like a sticky note on the wall) and who is still owed one. One item per custom Skill that is switched on, oldest first. label is its name and coins its coin price (1 coin = 1 cent, the same as a tip in dollars). stock_left and stock_total are numbers when it has limited stock and null when it has no limit, sold_out is true when none are left. owed_total is how many are owed in all, and owed is who: one row per name in the order they came in, count is how many that name is owed (2 or more when they redeemed it again), since is when the oldest of theirs came in. One drops off the list when the streamer marks it done. Names are the ones the alert showed, an anonymous tip is "Anonymous" |
// A menu slideshow: one item at a time, always your real menu.
const box = document.getElementById("slide");
let items = [];
let index = 0;
// Draw the current item, or one line when nothing is on offer.
function show() {
if (!items.length) {
box.textContent = "Menu opens when the stream is live";
return;
}
const item = items[index % items.length];
box.textContent = item.icon + " " + item.label + " " + (item.price_text || "");
box.style.opacity = item.available ? "1" : "0.5";
}
// Follow the menu. A new price or a sold out item shows up on its own.
landmark.data.watch("redeems", (data) => {
if (!data) return; // could not read it, keep what is shown
const open = data.redeems.filter((r) => r.available);
items = open.length ? open : data.redeems;
show();
});
// Next item every few seconds.
setInterval(() => {
index += 1;
show();
}, 4000);Limits
- No network: no
fetch, noXMLHttpRequest, no storage or cookies. Images, fonts, audio and scripts by URL do load. - HTML, CSS and JS: up to 200,000 characters each.
landmark.eventskeeps the newest 200. The chat replay after a load is up to 60 lines.varsandglobals: keys up to 60 characters, each value up to 8,000 characters once saved as JSON, up to 200 keys per element.landmark.tts: 600 characters per read, the live overlay only, up to 10 reads every 20 seconds per account.landmark.translate: the first 800 characters, up to 600 a minute per account.- A list setting keeps up to 100 rows. A shared element carries up to 60 settings and 100 saved values.
landmark.data: refreshed every 5 seconds, up to 240 reads a minute per overlay, 10 seconds before it resolves tonull.watchreads at most every 5 seconds.
Built-in sounds
These ship with Landmark and are free to use with new Audio() or landmark.sound.play(url):
/sounds/elements/confetti.mp3: celebratory pop/sounds/elements/wheel-spin.mp3·/sounds/elements/wheel-win.mp3: spin and win/sounds/elements/goal-reached.mp3: goal chime/sounds/elements/counter.mp3: short blip
Audio plays on the live overlay and is silent in previews. Some browsers only allow audio after the overlay's first interaction, which is fine for plays driven by events. Add a sound on/off toggle to _schema so streamers can mute.
Example: a milestone ladder
A persistent goal-style element that reads the milestones list setting above, keeps a running total of tips in landmark.vars, and shows the next few milestones. Each row stays one milestone, so sorting never mixes up amounts and titles.
const c = landmark.config || {};
const box = document.getElementById("ladder");
// The rows the streamer set, cheapest first.
const rows = (Array.isArray(c.milestones) ? c.milestones : [])
.filter((r) => r && Number(r.amount) > 0)
.sort((a, b) => Number(a.amount) - Number(b.amount));
let total = 0;
// Draw the next three milestones above the total.
function render() {
box.innerHTML = "";
const next = rows.filter((r) => Number(r.amount) > total).slice(0, 3);
for (const r of next) {
const line = document.createElement("div");
line.textContent = "$" + r.amount + " " + (r.title || "");
line.style.color = r.color || "#fafafa";
box.appendChild(line);
}
}
// Count both kinds of Landmark tip.
async function addTip(e) {
total += Number(e.usd_amount) || 0;
await landmark.vars.set("total", total);
render();
}
// Start from the saved total, then listen.
landmark.vars.get("total").then((v) => {
total = Number(v) || 0;
render();
});
landmark.on("tip", addTip);
landmark.on("superchat", (e) => {
if (e.platform === "landmark") addTip(e);
});Example: a chat box
Listens with landmark.on("chat") and honors a "max messages" setting. After a page load Landmark replays the last chat lines into the same handler, so the box refills without any extra code.
const box = document.getElementById("box");
const MAX = (landmark.config && landmark.config.max) || 30;
function render(e) {
const p = e.payload || {};
const row = document.createElement("div");
row.textContent = (p.user || "?") + ": " + (p.text || "");
box.appendChild(row);
while (box.children.length > MAX) box.removeChild(box.firstChild);
box.scrollTop = box.scrollHeight;
}
// Recent lines are replayed here after load, then it stays live.
landmark.on("chat", render);← Back to Elements · Elements & overlays → · TTS reference →