<script src="/js/hd-admin-inserter.js"></script> If you are using a bundler, import '/js/hd-admin-inserter.js'; works just as well. 5.2. Ensure the user role is exposed The default visibilityFn looks for window.currentUser.role . Add something like:
// Append to the chosen mount point. const mountEl = document.querySelector(cfg.mountPoint); if (!mountEl) console.error('HD Admin Inserter: mount point not found:', cfg.mountPoint); return; mountEl.appendChild(toolbar); ; HD Admin Inserter Script -PASTEBIN-
HDAdminInserter.init( visibilityFn: () => myAuth.isAdmin() ); Pass a custom config object to HDAdminInserter.init before DOMContentLoaded , or call HDAdminInserter.updateConfig later: <script src="/js/hd-admin-inserter
// Who sees the toolbar? Accepts a function that returns true/false. // By default we check a global `window.currentUser.role`. visibilityFn: () => const role = window.currentUser?.role , Add something like: // Append to the chosen mount point
// Toolbar style – minimal CSS (you can override later via CSS file) style: ` #hd-admin-toolbar position: fixed; top: 0; left: 0; right: 0; background: #1e1e1e; color: #fafafa; padding: 8px 16px; font-family: system-ui, sans-serif; display: flex; align-items: center; z-index: 9999; box-shadow: 0 2px 6px rgba(0,0,0,.4); #hd-admin-toolbar button margin-right: 12px; background: #333; border: none; color: #fff; padding: 4px 10px; cursor: pointer; #hd-admin-toolbar button:hover background: #555; `,
// ----------------------------------------------------------------- // 4️⃣ Core: build and mount the toolbar. // ----------------------------------------------------------------- const mountToolbar = (config = {}) => const cfg = ...DEFAULT_CONFIG, ...config ;
return btn; ;
