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 🙏

© 2025 – Pkg Stats / Ryan Hefner

founder-grab

v1.0.3

Published

Element selection SDK for embedded applications - capture user feedback on web pages

Readme

founder-grab

Element selection SDK for embedded applications. Allows users to visually select page elements and provide feedback for bug reports and change requests.

Features

  • 🎯 Visual element selection with hover overlay
  • 💬 Floating popover for collecting user feedback
  • ⌨️ Keyboard shortcuts (Cmd+Enter to submit, Escape to cancel)
  • 🎨 Customizable colors, borders, and z-index
  • 🔒 Origin validation for secure iframe communication
  • Lightweight with zero dependencies
  • 🚀 Built for Next.js but works anywhere

Installation

npm install founder-grab
# or
bun add founder-grab
# or
yarn add founder-grab

Quick Start (Next.js)

// app/layout.tsx
import { generateElementSelectorScript } from 'founder-grab';
import Script from 'next/script';

export default function RootLayout({ children }) {
  return (
    <html>
      <head>
        <Script id="element-selector" strategy="afterInteractive">
          {generateElementSelectorScript()}
        </Script>
      </head>
      <body>{children}</body>
    </html>
  );
}

With Custom Configuration

<Script id="element-selector" strategy="afterInteractive">
  {generateElementSelectorScript({
    primaryColor: '#8b5cf6',    // Purple (default)
    borderWidth: '2px',          // Border width (default)
    zIndex: 999999,              // Z-index for overlay (default)
    allowedOrigins: [            // Optional: restrict which parents can communicate
      'https://your-app.com'
    ]
  })}
</Script>

Usage

From Parent Application

Enable selection mode by sending a message to the iframe:

// In your parent application
const iframe = document.querySelector('iframe');

// Enable selection mode
iframe.contentWindow.postMessage({ type: 'ENABLE_SELECTION' }, '*');

// Disable selection mode
iframe.contentWindow.postMessage({ type: 'DISABLE_SELECTION' }, '*');

Listening for Selected Elements

// In your parent application
window.addEventListener('message', (event) => {
  if (event.data.type === 'ELEMENT_SELECTED') {
    const { html, notes, selector, tagName } = event.data;
    
    // Create a bug report or change request with this data
    console.log('Element HTML:', html);
    console.log('User notes:', notes);
    console.log('CSS selector:', selector);
    console.log('Tag name:', tagName);
  }
});

User Flow

  1. Parent application sends ENABLE_SELECTION message to iframe
  2. User sees crosshair cursor and purple hover overlay on elements
  3. User clicks an element
  4. Floating popover appears with textarea for feedback
  5. User describes what needs to be changed
  6. User confirms (Cmd+Enter or clicks Confirm)
  7. Data is sent to parent application via postMessage

API Reference

generateElementSelectorScript(config?)

Generates the inline script to inject into your page.

Parameters:

  • config (optional): Configuration object
    • primaryColor (string): Color for overlay and buttons (default: '#8b5cf6')
    • borderWidth (string): Width of selection border (default: '2px')
    • zIndex (number): Z-index for overlay (default: 999999)
    • allowedOrigins (string[]): Allowed parent origins for security (default: [])

Returns: String containing the inline script

Message Types

Parent → Iframe

{ type: 'ENABLE_SELECTION' }   // Enable selection mode
{ type: 'DISABLE_SELECTION' }  // Disable selection mode

Iframe → Parent

{
  type: 'ELEMENT_SELECTED',
  html: string,        // Element's outerHTML
  notes: string,       // User's feedback
  selector: string,    // CSS selector (e.g., '#id' or 'div.class')
  tagName: string      // Element tag name
}

TypeScript Support

Full TypeScript definitions included:

import type { 
  ElementSelectorConfig,
  ElementSelectedMessage,
  MessageHandler 
} from 'founder-grab';

How It Works

This package injects a self-contained script that:

  1. Listens for postMessage events from parent window
  2. Creates a hover overlay that follows the mouse in selection mode
  3. Captures clicks using capture phase event handling to prevent triggering buttons/links
  4. Shows a floating popover for collecting user feedback
  5. Sends element data back to parent via postMessage

See IFRAME_COMMUNICATION.md for detailed technical documentation.

Security

  • Origin validation can be enabled via allowedOrigins config
  • All communication happens via postMessage API
  • No data is sent to external servers
  • Script is self-contained with no external dependencies

Browser Support

  • Modern browsers (Chrome, Firefox, Safari, Edge)
  • Requires ES6+ support
  • No polyfills needed

License

MIT

Contributing

Issues and PRs welcome at github.com/your-org/founder-grab