npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

directus-extension-hook-admin-script-injector

v1.2.0

Published

Inject Directus admin JavaScript from a Directus collection

Downloads

69

Readme

directus-extension-hook-admin-script-injector

Inject JavaScript into Directus Studio from a Directus collection.

What it does

The extension injects this external script into Directus Studio:

<script src="/admin-script-injector.js" defer></script>

The endpoint reads all published JavaScript snippets from:

admin_script_injector

Then it concatenates them in this order:

sort ASC
id ASC

This avoids inline JavaScript and does not require CSP unsafe-inline.

Directus collection to create manually

Create a regular collection named:

admin_script_injector

Recommended fields:

status
  Type: String
  Interface: Dropdown
  Choices:
    published
    draft
    archived
  Required: true
  Purpose: only published records are injected

sort
  Type: Integer
  Required: false
  Purpose: controls execution order

name
  Type: String
  Required: true
  Purpose: short description of what this script does

script
  Type: Text
  Interface: Code or Textarea
  Required: false
  Purpose: JavaScript to inject into Directus Studio

Keep the default id field.

Example records

status: published
sort: 100
name: Hide actions on gerar collections
script: console.log('hide actions loaded');

status: published
sort: 200
name: Auto discard gerar changes
script: console.log('auto discard loaded');

CSP requirement

The script is loaded from the same Directus origin.

Required CSP:

script-src 'self'

No unsafe-inline is required.

Browser verification

Open Directus Studio and run:

document.querySelector('script[src="/admin-script-injector.js"]') !== null

Expected:

true

Then open:

/admin-script-injector.js

Expected:

The concatenated JavaScript from all published admin_script_injector records.

Security

Anyone who can edit admin_script_injector.script can execute JavaScript inside Directus Studio.

Only technical admins should have write access to this collection.