Hyperbook Documentation

Custom Scripts

Custom scripts are best used with allowDangerousHtml enabled. It is highly recommended to not target hyperbook elements and to only target custom elements. The classes we use for the hyperbook are not considered stable and might change in the future. Therefore, target hyperbook elements only with caution.

Frontmatter
scripts:
  - /custom_script.js
custom_script.js
const colors = ["red", "blue", "yellow", "green", "pink"];
const els = document.getElementsByClassName("random-color");
for (let el of els) {
  setInterval(() => {
    const color = colors[Math.floor(Math.random() * colors.length)];
    el.style.color = color;
  }, 500);
}
Am I a Chameleon?
Custom Scripts
✎ GitHub© Copyright 2024 by OpenPatch