For AI assistants

For AI assistants

All the docs in one text: paste it into an AI chat, then describe the widget you want.

Markdown

Instructions for AI assistants

This page is for AI assistants that write or change custom widgets for Streamed. It comes first in llms-full.txt, which holds all the docs in one file; llms.txt lists the pages.

A Streamed custom widget is an HTML/CSS/JS page with the same API as a StreamElements custom widget. Use only what these docs describe. Where Streamed differs from StreamElements, these docs are right.

Answer format

Answer with exactly these five files, each in its own code block, under a heading with its file name:

  1. widget.html: the markup inside <body> only (no <html>, <head>, <body>, <script> or <style> tags)
  2. widget.css
  3. widget.js
  4. fields.json: an object of fields, { "name": { "type", "label", "value", "group" } }
  5. data.json: the value of every field that has one (the same as its value), { "name": value }. Leave out button fields.

When changing an existing widget, still give all five files in full, so they can be imported as they are. Then say in one or two sentences how to use it: which events or variables it needs, which buttons it has. The user saves the files and imports them with the Import button of the overlay editor's code editor.

Rules

  1. Events. Listen with window.addEventListener('onWidgetLoad' | 'onEventReceived' | 'onSessionUpdate', …). Use only the listeners in Events: follower-latest, subscriber-latest, sponsor-latest, cheer-latest, raid-latest, tip-latest, superchat-latest, message, delete-message, delete-messages, bot:counter, kvstore:update, widget-button. Never rely on event:test.
  2. Platforms. On YouTube, subscriber-latest is a new channel subscriber, sponsor-latest a membership, superchat-latest a Super Chat. Ko-fi tips are tip-latest. Handle the kinds the user asks for, and check event.platform where it matters.
  3. amount is months (subscriber, sponsor), bits (cheer), viewers (raid), money (tip, superchat, with event.currency), the number of gifts (bulkGifted), or 0 (follower).
  4. Gift bundles. A bundle arrives as one bulkGifted event and then one isCommunityGift event per recipient. Show the bundle and skip the recipients, unless asked otherwise.
  5. Untrusted text. Insert name, message, sender, data.text, data.displayName with textContent (jQuery .text()), never innerHTML, .html() or HTML strings. Only a chat message's renderedText is safe as HTML.
  6. Settings. Make every text, color, size, font, duration and choice the user may want to change a field. In JS read values from obj.detail.fieldData in onWidgetLoad; use {{fieldName}} only in HTML and CSS. Never write {word} or ${word} in JS where word is a field name: it is replaced as a placeholder. Use googleFont fields for fonts (they load by themselves) and image-input / sound-input / video-input for media.
  7. Queue. For alerts that must not overlap, add a hidden widgetDuration field (seconds, a little longer than the longest alert) and call SE_API.resumeQueue() when an alert ends and for every alert event the widget does not show. Widgets that must react at once to every event (counters, goals, trains, lists) must not have a widgetDuration field.
  8. Keeping values. No localStorage, sessionStorage, indexedDB or cookies: use SE_API.store (keys [A-Za-z0-9_-]{1,64}, values up to 64 KB, 10 writes per 10 s). Its kvstore:update keys start with customWidget.. Variables (SE_API.counters.get, bot:counter) are read-only.
  9. Buttons. button fields fire widget-button in every open copy of the widget. If a click changes the store, only write when overlay.isEditorMode is true.
  10. Network. Only https:/wss: addresses. fetch comes from the origin null without cookies, so only APIs that allow any origin work. Never put API keys or secrets into a widget.
  11. Layout. The page is exactly the layer's size and transparent. Position the content with position: absolute; inset: 0; or flexbox; avoid scrollbars; keep text readable on any background (shadow or a backdrop).
  12. Editor preview. When the widget would be empty until an event comes, show sample content when obj.detail.overlay.isEditorMode is true.
  13. Plain code. Modern JavaScript, no build step, no modules, no frameworks unless loaded from an HTTPS CDN. jQuery is already there as $.

Before answering, check

  • All five files are there, and fields.json and data.json are valid JSON objects.
  • Every {{name}} in HTML and CSS is a field.
  • No viewer text reaches innerHTML.
  • Every alert path calls SE_API.resumeQueue() when widgetDuration is used.
  • Nothing uses localStorage, alert(), http: addresses or StreamElements' REST API.

Connection lost

Couldn't reach the Streamed server. Either your internet is down, there's maintenance going on in the background, or who knows.. maybe something really is wrong on our end.

Trying again…