v1.0.0

AdSense & Donation Banners

A small module for showing a dismissible donation banner or a Google AdSense unit at the top, bottom, or sidebar of your page. This is the module that powers the banner on this documentation site.

πŸ’‘ Site-only module. Unlike most modules on this site, onigiri-adsense.js isn't part of the core OnigiriJS framework repository - it ships alongside this documentation site's own source, in static/js/.

Features

  • Donation banner - a configurable call-to-action banner with a donate link and a close button
  • AdSense banner - injects an <ins class="adsbygoogle"> unit and loads the AdSense script for you
  • Dismiss memory - remembers a dismissal for a configurable duration, via Onigiri.storage when available, falling back to localStorage
  • Escaped by default - banner title/message/button text are HTML-escaped before rendering, so values pulled from a CMS field or translation file can't inject markup

Quick Start

1. Include the Module

<script src="/static/js/onigiri-adsense.js"></script>
Note: this module lives in this site's own static/js/ directory, not the framework's jsDelivr-hosted src/framework/ tree - point your <script> tag at wherever you've copied it in your own project.

2. Initialize

Onigiri.adsense.init({
    enableDonation: true,
    enableAdSense: false,
    donationUrl: 'https://github.com/sponsors/your-username',
    position: 'top',
    dismissible: true,
    autoShow: true
});
βœ… That's it! A donation banner will appear automatically if autoShow is enabled.

API Reference

Configuration Options

Option Type Default Description
adClientStringnullYour AdSense publisher ID (e.g. ca-pub-xxxxxxxx)
adSlotStringnullDefault ad slot ID
autoShowBooleantrueShow a banner automatically on init()
dismissibleBooleantrueShow a close button and remember the dismissal
dismissCookieNameString'onigiri_donation_dismissed'Storage key used to remember the dismissal
dismissDurationNumber604800000 (7 days)How long a dismissal is remembered, in milliseconds
positionString'top''top', 'bottom', or 'sidebar'
animationDurationNumber300Fade in/out duration in milliseconds
donationUrlStringnullLink used for the donate button
donationTextString'Support our project'Reserved for future use in the default template
enableAdSenseBooleanfalseShow an AdSense unit instead of/alongside the donation banner
enableDonationBooleantrueShow the donation banner

When both enableDonation and enableAdSense are true, showBanner() shows the donation banner (it's checked first). Call createAdSenseBanner() directly if you want both on the page at once.

Methods

Onigiri.adsense.init(options)

Merges your options into the module config, injects the module's stylesheet, checks whether the banner was previously dismissed, and (if autoShow is true) shows a banner. Safe to call once per page load.

Onigiri.adsense.showBanner()

Creates and mounts a banner based on the current config (enableDonation vs enableAdSense). Does nothing if the banner was already dismissed within dismissDuration.

Onigiri.adsense.createDonationBanner(options)

Builds (but doesn't mount) a donation banner. Returns { id, element, mount(), unmount() }.

const banner = Onigiri.adsense.createDonationBanner({
    title: 'Enjoying OnigiriJS?',
    message: 'Consider sponsoring development.',
    theme: 'dark'
});
banner.mount();

Onigiri.adsense.createAdSenseBanner(options)

Builds (but doesn't mount) an AdSense banner. Requires adClient to be configured. Returns the same { id, element, mount(), unmount() } shape.

Onigiri.adsense.clearDismissed()

Clears the stored dismissal, so the banner will show again on the next showBanner() call.

Events

EventFired when
onigiri:adsense:readyinit() has finished
onigiri:adsense:mountedA banner has been added to the page (detail: { bannerId, element })
onigiri:adsense:unmountedA banner has been removed (detail: { bannerId })
onigiri:adsense:dismissedThe visitor closed a dismissible banner (detail: { bannerId })

Security Notes

  • Banner title, message, and button text are HTML-escaped before being inserted into the page (via Onigiri.security.sanitizeHTML when loaded, or an inline fallback otherwise). If you source these strings from a translation file or CMS, this prevents an edited string from injecting markup.
  • The dismiss flag is stored client-side (via Onigiri.storage or localStorage) - it is not a server-verified consent record.

βœ… Development Roadmap

Track the progress of OnigiriJS modules. Tasks are marked complete by the development team.

OnigiriJS Module Roadmap

Implementation progress of planned modules

6 / 21 completed (29%)
onigiri-state
Shared global & scoped state management
onigiri-directives
Declarative DOM bindings (o-show, o-model, etc.)
onigiri-resource
REST-style data models over AJAX
onigiri-observe
Intersection & Mutation observer helpers
onigiri-humhub-ui
Standard HumHub UI abstractions (modal, notify, confirm)
onigiri-lifecycle
Component lifecycle hooks
onigiri-guard
Debounce, throttle, single-run guards
onigiri-scroll
Scroll save/restore & helpers (PJAX-friendly)
onigiri-permission
Client-side permission awareness
onigiri-portal
DOM teleport / overlay mounting
onigiri-router
Micro router (non-SPA, PJAX-first)
onigiri-sanitize
HTML & input sanitization
onigiri-shortcut
Keyboard shortcut manager
onigiri-queue
Sequential async task runner
onigiri-gesture
Touch & swipe helpers
onigiri-devtools
Debugging & inspection helpers
onigiri-plugin
Plugin registration system
onigiri-time
Relative time & timezone utilities
onigiri-emojis
Emoji Picker and Manager
onigiri-tasks
Task Management
onigiri-polls
Polls creation and management
Note: Task completion is managed by the OnigiriJS development team.