Skip to content

BYOLLM - Context injection widget for the AI age. Let users copy-paste your content into ChatGPT, Claude, or any LLM. Zero dependencies, zero backend, works forever.

License

Notifications You must be signed in to change notification settings

collapseindex/collapsedrop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CollapseDrop v1.1.0 - README

BYOLLM - Bring Your Own LLM context injection for static sites

Live Demo Ko-fi License

CollapseDrop Example

πŸ€” Stop AI making up stuff about your site. Start real conversations!

Users will ask AI about your product anyway. Give them the source of truth instead of letting them get garbage from random web scrapes.

Browser AI assistants can't actually understand your site fully. Screenshots miss details. Scraping gets messy. Give YOUR users/customers curated text context - it's the only thing that actually works.

Perfect for complex content:

  • Technical documentation β€” Let AI explain your API/SDK to newcomers
  • Research papers & whitepapers β€” Make dense content accessible
  • Legal/compliance docs β€” Help users understand terms without a lawyer
  • Academic writing β€” Students/readers can ask questions about your work
  • Open source projects β€” Help devs understand your codebase
  • Internal wikis β€” Onboard new team members faster

If someone unfamiliar with your work needs to understand it, CollapseDrop bridges the gap.


βœ… See It Live

collapseindex.org - Real-world example of CollapseDrop in action

πŸ“ examples/vanilla.html - See all features: tabs, custom colors, branding, themes & more


⚑ Why CollapseDrop?

The problem:

User: "Hey ChatGPT, what does [your product] do?"
ChatGPT: *hallucinates confidently from 2-year-old blog posts*

The solution:

User: *clicks Copy* β†’ *pastes into ChatGPT* β†’ "What does this do?"
ChatGPT: *actually accurate because YOU provided the context*

BYOLLM vs Traditional Chatbots

Traditional Chatbot CollapseDrop (BYOLLM)
πŸ’Έ Pay for API calls βœ… Free forever
πŸ–₯️ Maintain backend βœ… Zero infrastructure
πŸ”’ Locked to one LLM βœ… Works with ANY LLM
😬 Users don't trust it βœ… Users trust their own AI
πŸ“Š You process user data βœ… Zero data processing
πŸ“‹ GDPR compliance needed βœ… No data = no GDPR
πŸ’€ Breaks when API changes βœ… Works forever

One-Click vs Select-Drag

Manual Copy (Select + Drag) CollapseDrop (One Click)
πŸ–±οΈ Click, hold, drag to select βœ… One tap/click
😀 Miss a line? Start over βœ… Always gets everything
πŸ“± Nightmare on mobile βœ… Works perfectly on mobile
🎯 Hope you got it all βœ… Pre-formatted, ready to paste
❓ What do I even copy? βœ… Context is curated for AI
πŸ”„ Repeat for every section βœ… Tabs organize everything

Your users shouldn't fight their browser to copy text.

Why Not Browser AI Assistants? (Leo, Aria, etc.)

Browser AI (Leo, Aria, etc.) CollapseDrop
🀷 Grabs whatever it wants from page βœ… YOU curate the context
πŸ”€ Weird formatting breaks context βœ… Clean, pre-formatted text
πŸ“„ Forgets context between pages βœ… User pastes exactly what they need
🎰 Hit or miss on complex layouts βœ… Works on any page structure
πŸ”’ Locked to that browser's AI βœ… Works with ChatGPT, Claude, Grok, anything
😡 Struggles with SPAs/dynamic content βœ… Static text, always reliable

Browser AI assistants scrape pages blindly. You know your content better! Curate it.


πŸš€ Quick Start

Option 1: CDN (Easiest)

<!-- Add to your <head> -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/collapsedrop/dist/collapsedrop.css">
<script src="https://cdn.jsdelivr.net/npm/collapsedrop/dist/collapsedrop.js"></script>
<!-- Add anywhere in your page -->
<div data-collapsedrop 
     data-title="Ask AI About Us"
     data-subtitle="Copy and paste into ChatGPT, Claude, or any LLM">
[CONTEXT: You are explaining our product to a potential customer.]

PRODUCT OVERVIEW
================
We help teams collaborate better with real-time tools.

PRICING
β€’ Free: Up to 3 users
β€’ Pro: $10/user/month  
β€’ Enterprise: Contact us

--- ASK ABOUT ---
β€’ Features & integrations
β€’ Pricing & billing
β€’ Technical requirements
</div>

That's it. Widget auto-initializes. Zero config required.

Option 2: npm

npm install collapsedrop
import CollapseDrop from 'collapsedrop';
import 'collapsedrop/dist/collapsedrop.css';

CollapseDrop.init('#my-context', {
  title: 'Ask AI About Our Product',
  theme: 'dark'
});

Option 3: Self-Host

Download collapsedrop.js and collapsedrop.css from the dist folder.


πŸ”Œ Integrations

CollapseDrop is vanilla JS β€” it works everywhere HTML works.

Platform How to Use
React / Next.js Use useEffect to call CollapseDrop.init() after mount
Vue / Nuxt Call CollapseDrop.init() in onMounted()
Svelte Call in onMount() or use action
Astro Add script with is:inline, or use in client component
WordPress Enqueue scripts, add shortcode or Gutenberg block
Webflow Paste into page <head> embed + HTML embed for widget
Framer Use Code Override or HTML embed component
Squarespace Code Injection (header) + Code Block
Wix Velo custom code or HTML iframe
Notion Sites Super.so / Potion β€” custom code injection
Docusaurus Add to scripts in config, use in MDX
GitBook Custom HTML blocks
Hugo / Jekyll / 11ty Include in templates, auto-init handles the rest
Shopify Theme liquid + asset files

React Example:

import { useEffect, useRef } from 'react';

function AIContext({ content }) {
  const ref = useRef();
  
  useEffect(() => {
    if (ref.current) {
      new CollapseDrop(ref.current, {
        title: 'Ask AI',
        theme: 'dark'
      });
    }
  }, []);
  
  return <div ref={ref}>{content}</div>;
}

Vue Example:

<script setup>
import { onMounted, ref } from 'vue';

const el = ref(null);

onMounted(() => {
  new CollapseDrop(el.value, { title: 'Ask AI' });
});
</script>

<template>
  <div ref="el">Your context here...</div>
</template>

✨ Features

Feature Description
Zero Dependencies Single vanilla JS file, works anywhere
Auto-Init Just add data-collapsedrop attribute
Token Counter Shows estimated tokens & characters
Copy Button One-click copy with visual feedback
Share Button Native mobile share or clipboard fallback
Dark/Light Themes Built-in themes + full CSS customization
Multi-Tab Support Organize content into switchable tabs
Custom Branding Add your logo + background images
Multi-Language Token estimation for EN, KO, CN, JP
Accessible Keyboard navigation, ARIA labels
Mobile Responsive Works on all screen sizes
XSS Protected All inputs sanitized

🎨 Customization

Basic Options (Data Attributes)

<div data-collapsedrop
     data-title="Your Title"
     data-subtitle="Your subtitle"
     data-theme="dark"
     data-language="english"
     data-collapsed="false"
     data-show-tokens="true"
     data-show-share="true">
  Your content here...
</div>

Multi-Tab Mode

<div data-collapsedrop data-title="Documentation">
  <div data-tab="Overview">Overview content...</div>
  <div data-tab="Pricing">Pricing content...</div>
  <div data-tab="API">API docs...</div>
</div>

Custom Branding

<div data-collapsedrop
     data-logo="https://yoursite.com/logo.png"
     data-logo-size="40px"
     data-background-image="https://yoursite.com/hero.jpg"
     data-background-overlay="0.85">

Custom Colors

<div data-collapsedrop
     data-color-bg="#1a1025"
     data-color-border="#6b21a8"
     data-color-text="#e9d5ff"
     data-color-title="#c084fc"
     data-color-btn-bg="#9333ea"
     data-color-btn-hover="#7c3aed">

JavaScript API

const widget = CollapseDrop.init('#my-context', {
  title: 'Ask AI',
  subtitle: 'Copy and paste into any LLM',
  theme: 'dark',
  language: 'english',
  collapsed: false,
  showTokens: true,
  showChars: true,
  showShare: true,
  maxHeight: '500px',
  // Branding
  logo: '/images/logo.svg',
  logoSize: '32px',
  backgroundImage: '/images/bg.jpg',
  backgroundOverlay: 0.85,
  // Multi-tab
  tabs: [
    { label: 'Overview', content: '...' },
    { label: 'Pricing', content: '...' }
  ],
  activeTab: 0,
  // Callbacks
  onCopy: (content) => console.log('Copied!'),
  onShare: (content) => console.log('Shared!'),
  onExpand: () => {},
  onCollapse: () => {},
  onTabChange: (index, tab) => {}
});

// Methods
widget.copy();           // Trigger copy
widget.share();          // Trigger share
widget.toggle();         // Toggle collapse
widget.expand();         // Expand
widget.collapse();       // Collapse
widget.setContent(text); // Update content
widget.getContent();     // Get current content
widget.switchTab(1);     // Switch to tab index
widget.destroy();        // Remove widget

🎯 Use Cases

  • Product Landing Pages β€” Let visitors ask AI about your product
  • Documentation Sites β€” AI-ready context for complex docs
  • SaaS Apps β€” Onboarding help without building a chatbot
  • Company FAQs β€” Support without a support team
  • Open Source Projects β€” Help users understand your code
  • Personal Portfolios β€” Let recruiters ask AI about you
  • E-commerce β€” Product info that AI can actually use

πŸ“Š Token Estimation

Language Chars/Token Example
English ~4 "Hello world" β‰ˆ 3 tokens
Korean ~2 "μ•ˆλ…•ν•˜μ„Έμš”" β‰ˆ 3 tokens
Chinese ~1.5 "δ½ ε₯½δΈ–η•Œ" β‰ˆ 3 tokens
Japanese ~2 "こんにけは" β‰ˆ 3 tokens
Mixed ~3 Multilingual content

Estimates for UI display. Actual tokenization varies by model.


🌐 Browser Support

Browser Version
Chrome 66+
Firefox 63+
Safari 13.1+
Edge 79+

Graceful fallback for clipboard API on older browsers.


β˜• Support the Project

Support on Ko-fi

CollapseDrop is 100% free and open source - no paywalls, no premium tiers, no BS.

If it saved you time, helped your project, or you just think it's cool:

Way to Support Link
β˜• Buy me a coffee ko-fi.com/collapseindex
⭐ Star on GitHub Hit that star button above!
πŸ“’ Share it Tweet it, post it, tell a friend

Built solo on an 8GB Ideapad 3. Every coffee helps fuel more open source! β˜•


οΏ½ Security

CollapseDrop is built with security in mind:

Protection Status
XSS Prevention βœ… All inputs escaped/sanitized
Runtime Dependencies βœ… Zero (no supply chain risk)
External Requests βœ… None (no tracking, no analytics)
Data Collection βœ… None (100% client-side)
eval() / dangerous patterns βœ… None

Audited: January 2026 β€” All XSS vectors patched

See SECURITY.md for full security policy and vulnerability reporting.


οΏ½πŸ“„ License

Free to use, modify, and share. Just don't sell it.

  • βœ… Use on any website (commercial or personal)
  • βœ… Modify and customize freely
  • βœ… Include in free/open source projects
  • ❌ Don't sell it or include in paid templates/products

See LICENSE for full details.


πŸ™ Attribution

Not required, but appreciated:

<!-- Powered by CollapseDrop - https://github.com/collapseindex/collapsedrop -->

Or link to collapseindex.org πŸ’™


Built by Collapse Index Labs - Alex Kwon
One person. 8GB Ideapad 3. Making AI interactions better.

About

BYOLLM - Context injection widget for the AI age. Let users copy-paste your content into ChatGPT, Claude, or any LLM. Zero dependencies, zero backend, works forever.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published