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:
widget.html: the markup inside<body>only (no<html>,<head>,<body>,<script>or<style>tags)widget.csswidget.jsfields.json: an object of fields,{ "name": { "type", "label", "value", "group" } }data.json: the value of every field that has one (the same as itsvalue),{ "name": value }. Leave outbuttonfields.
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
- 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 onevent:test. - Platforms. On YouTube,
subscriber-latestis a new channel subscriber,sponsor-latesta membership,superchat-latesta Super Chat. Ko-fi tips aretip-latest. Handle the kinds the user asks for, and checkevent.platformwhere it matters. amountis months (subscriber, sponsor), bits (cheer), viewers (raid), money (tip, superchat, withevent.currency), the number of gifts (bulkGifted), or0(follower).- Gift bundles. A bundle arrives as one
bulkGiftedevent and then oneisCommunityGiftevent per recipient. Show the bundle and skip the recipients, unless asked otherwise. - Untrusted text. Insert
name,message,sender,data.text,data.displayNamewithtextContent(jQuery.text()), neverinnerHTML,.html()or HTML strings. Only a chat message'srenderedTextis safe as HTML. - 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.fieldDatainonWidgetLoad; use{{fieldName}}only in HTML and CSS. Never write{word}or${word}in JS wherewordis a field name: it is replaced as a placeholder. UsegoogleFontfields for fonts (they load by themselves) andimage-input/sound-input/video-inputfor media. - Queue. For alerts that must not overlap, add a hidden
widgetDurationfield (seconds, a little longer than the longest alert) and callSE_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 awidgetDurationfield. - Keeping values. No
localStorage,sessionStorage,indexedDBor cookies: useSE_API.store(keys[A-Za-z0-9_-]{1,64}, values up to 64 KB, 10 writes per 10 s). Itskvstore:updatekeys start withcustomWidget.. Variables (SE_API.counters.get,bot:counter) are read-only. - Buttons.
buttonfields firewidget-buttonin every open copy of the widget. If a click changes the store, only write whenoverlay.isEditorModeistrue. - Network. Only
https:/wss:addresses.fetchcomes from the originnullwithout cookies, so only APIs that allow any origin work. Never put API keys or secrets into a widget. - 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). - Editor preview. When the widget would be empty until an event comes, show sample content when
obj.detail.overlay.isEditorModeistrue. - 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.jsonanddata.jsonare valid JSON objects. - Every
{{name}}in HTML and CSS is a field. - No viewer text reaches
innerHTML. - Every alert path calls
SE_API.resumeQueue()whenwidgetDurationis used. - Nothing uses
localStorage,alert(),http:addresses or StreamElements' REST API.