Cross-origin pages
If your page is not served from captcha.vperked.online, set endpoint on the widget (or a meta tag). Verify and consume call that host with CORS. Any http(s) site can embed; you do not need an origin allowlist.
<meta name="perk-endpoint" content="https://captcha.vperked.online">
<captcha-widget name="captcha_token" action="checkout"></captcha-widget>
import { configure, consumeToken } from 'https://captcha.vperked.online/static/captchaWidget.js';
configure({ endpoint: 'https://captcha.vperked.online', action: 'checkout' });
const res = await consumeToken(token); // action from configure()
Privacy browsers (Brave, Firefox strict) may block third-party cookies. The widget resends the session id from the challenge response in the verify body—no extra wiring needed.
JavaScript API
| Export | Purpose |
configure({ endpoint, action, debug }) |
Defaults for fetch helpers. HTML attributes on <captcha-widget> still win. |
consumeToken(token, action?) |
Spend a token from the browser with the headers Perk expects. |
window.PerkCaptcha |
Same helpers without import: CaptchaWidget, configure, consumeToken. |
Attributes
| Attribute | Default | Meaning |
name |
captcha_token |
Hidden input name after verify. |
endpoint |
script origin |
Perk host when the page is on another site. |
action |
default |
Binds the token. Must match consume. |
scheme |
inherit |
Follows the page. Force dark or light. |
notify |
off |
Optional error toasts. Success stays in the widget only. |
allow-frame |
off |
Opt in to running inside an iframe. Default rejects framed embeds. |
Closed shadow root (::part still works). The hidden token is in light DOM for forms — host XSS can read it; consume immediately. Browser evaluate() is advisory; the server decides.
Events
| Event | When |
captcha-verified |
Token ready. detail.captcha_token matches the hidden field. |
captcha-error |
Failed; the widget locks until the page is refreshed. Use detail.body for copy. |
Theming
Optional CSS variables. Live skins: customize.
captcha-widget {
--perk-accent: #fff;
--perk-bg: #000;
--perk-fg: #fff;
--perk-radius: 14px;
}