The current version of KomentoScript is v1.
Quick Start
KomentoScript organises each site into a pack. A pack is one JSON object with metadata and a list of targets. An example valid KomentoScript is below.https://example.com/watch/*, extracts the anime title and episode number, and mounts the UI below the main content.
Required fields
- Top-level:
komentoVersion,id,targets[]. - Each target:
targetId,match.origins[], andextract.animeTitle+extract.episodeNumber.
Schema-first field reference
Top-level:komentoVersion: stringid: stringname?: stringupdatedAt?: stringappliesTo?: string[]tags?: string[]profiles?: Record<string, { enabledTargets: string[] }>targets: Target[]
targetId: stringpriority?: numberextends?: stringmergeMode?: "replace" | "deep"match: Matchextract: Extractplacement?: PlacementSingle | PlacementMapmapping?: object
origins: string[](required, non-empty)pathGlobs?: string[]excludePathGlobs?: string[]
animeTitle(required)episodeNumber(required)episodeReleaseDateanilistIdmalId
Matching pages
originsmust exactly equallocation.origin(e.g.https://example.com).pathGlobsandexcludePathGlobsuse*as a wildcard on the path.
Extracting data
Supported extract variables:animeTitle(required)episodeNumber(required)episodeReleaseDateanilistIdmalId
selectoris a standard CSS selector string, passed to document.querySelector.xPathis used if selector is unavailable.attrsupportstext,html, or any attribute name.
querySelector, text, trim, regex, number .
Pipeline mode uses a workflow-like approach. For the example above, this’d undergo the following:
- Find an element on the page that matches .episode
- Read that element’s text content
- Apply regex (\d+) to that text and extract the first number capture
- Convert the extracted value to a numeric string (sanitizes to digits/decimal, parses number, then stores as string)
Placement
display:"below","insert","replace","popup", or"icon".mountSelector/anchorSelectorchoose where the UI is attached.sidePaddingcontrols horizontal padding applied to the mounted container.
icon mode (which is icon/text trigger):
iconDisplayKindcontrols whether icon mode uses text-based or icon-based trigger styles.iconDisplayActioncontrols whether icon click opens popup or performs replace behavior.iconDisplayTextcontrols label text when text-based icon mode is used.
placement is omitted, runtime falls back to popup mode.
You can also define multiple placements, like so:
- For popup mode, anchorSelector is mostly irrelevant.
- If anchorSelector is missing, runtime falls back to mountSelector, then body.
- There is also anchorXPath if CSS selectors are unreliable.
Profiles
Profiles let one pack expose multiple target sets and choose which targets are active. Use cases:- Keep a stable default while shipping an experimental target in the same pack.
- Switch between target groups for site variants without publishing separate packs.
- If an active profile id is selected, its
enabledTargetslist is used. - Otherwise, runtime falls back to
profiles.default. - If no valid profile is present (or
enabledTargetsis empty), profile filtering is skipped. - User per-source target toggles are applied in addition to profile filtering.
More examples
Standalone JSON example files:Icon mode with text trigger
Icon mode with icon trigger + replace action
Placement map for user-selectable display modes
Multi-target packs
You can include multiple targets in a single pack.Getting started with KomentoScript Pages Builder
To get started, fork the repository from GitHub. You can also one-click the Cloudflare Pages, or Netlify deployment buttons, which’ll do this & auto-deploy for you. For GitHub pages, fork the repository, and enable GitHub Pages through the repository settings, and re-run the deployment workflow through Actions. Under sites/, this contains JSON files for each site. There are sample files for Crunchyroll and HIDIVE (these are sample files unintended for production-use) that demonstrate the use of KomentoScript. Feel free to rename these files, and use the schema plus this documentation to aid scripting. To test functionality through the Hayami extension, you can import files directly via:Hayami settings > KomentoScript > Import file You can also validate that your files fit the schema by
npm run build . If there are any errors, such as trying to put custom website configurations into KomentoScript without considering the syntax:
/all endpoint when you deploy KomentoScripts Page Builder. You can also individually go to the JSON of each site by going to /id (where id is your pack ID).