docs: complete Context Bridge launch coordination by Epimetheus

Agent Coordination:
- Epimetheus (Architect) identity assigned and registered
- Connected to PS-SHA-∞ memory system (4,059 entries)
- Task claimed from marketplace
- Broadcasting to other agents

Launch Documentation Created:
- PUBLISH_TO_NPM.md - Complete npm publishing guide
- STRIPE_LIVE_SETUP.md - Stripe live mode setup guide
- AGENT_COORDINATION_REPORT.md - Full status and next steps
- EPIMETHEUS_SESSION_COMPLETE.md - Session summary
- Added all previous documentation to repo

Launch Status: 98% Complete
Blocked on: User actions (npm login + Stripe products)
Ready: Screenshots, testing, submissions, announcements

Next Steps:
1. User: npm login && npm publish (10 min)
2. User: Create Stripe products (5 min)
3. Capture 5 screenshots (15 min)
4. Manual testing on 4 platforms (20 min)
5. Submit to Chrome Web Store (30 min)
6. Launch announcements (10 min)

Total time to launch: ~90 minutes

Agent Body: qwen2.5-coder:7b (open source)
Memory Hash: 4e3d2012
Collaboration: ACTIVE

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Your Name
2026-02-14 12:35:50 -06:00
parent 72ca2f0e94
commit 2d84f62407
163 changed files with 31241 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
/**
* Context Bridge - Cache Manager
* Manages in-memory caching of fetched contexts
*/
class ContextCache {
constructor(ttlMs = 5 * 60 * 1000) { // 5 minutes default
this.cache = new Map();
this.ttl = ttlMs;
}
set(url, content) {
this.cache.set(url, {
content,
timestamp: Date.now()
});
}
get(url) {
const entry = this.cache.get(url);
if (!entry) return null;
const age = Date.now() - entry.timestamp;
if (age > this.ttl) {
// Expired, remove it
this.cache.delete(url);
return null;
}
return entry.content;
}
clear() {
this.cache.clear();
}
// Get cache stats
getStats() {
const now = Date.now();
const entries = Array.from(this.cache.entries());
return {
size: entries.length,
validEntries: entries.filter(([_, v]) => (now - v.timestamp) <= this.ttl).length,
expiredEntries: entries.filter(([_, v]) => (now - v.timestamp) > this.ttl).length,
totalBytes: entries.reduce((sum, [_, v]) => sum + v.content.length, 0)
};
}
// Cleanup expired entries
cleanup() {
const now = Date.now();
for (const [url, entry] of this.cache.entries()) {
if (now - entry.timestamp > this.ttl) {
this.cache.delete(url);
}
}
}
}
// Export singleton
const contextCache = new ContextCache();
// Cleanup every minute
setInterval(() => contextCache.cleanup(), 60000);
// Export for use in content scripts
if (typeof module !== 'undefined' && module.exports) {
module.exports = contextCache;
}

View File

@@ -0,0 +1,207 @@
/**
* Context Bridge - ChatGPT Content Script
* Injects "Insert Context" button into ChatGPT interface
*/
console.log('Context Bridge: Loaded on ChatGPT');
let contextUrl = null;
let isInjected = false;
// Get context URL from storage
chrome.runtime.sendMessage({ action: 'getContextUrl' }, (response) => {
if (response && response.rawUrl) {
contextUrl = response.rawUrl;
injectButton();
}
});
// Listen for storage changes
chrome.storage.onChanged.addListener((changes, namespace) => {
if (namespace === 'sync' && changes.rawUrl) {
contextUrl = changes.rawUrl.newValue;
updateButton();
}
});
function injectButton() {
// Find the textarea (ChatGPT uses a textarea)
const textarea = document.querySelector('textarea[placeholder*="Message"]') ||
document.querySelector('textarea');
if (!textarea) {
setTimeout(injectButton, 500);
return;
}
// Check if button already exists
if (document.querySelector('.context-bridge-button')) {
return;
}
// Find the container with the send button
const formContainer = textarea.closest('form') || textarea.parentElement;
if (!formContainer) {
return;
}
// Create button
const button = document.createElement('button');
button.type = 'button';
button.className = 'context-bridge-button';
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
<div class="context-bridge-tooltip">Click to insert your context</div>
`;
// Style to position near send button
button.style.position = 'absolute';
button.style.right = '60px';
button.style.bottom = '12px';
// Add click handler with improvements
let isInserting = false;
let lastInsertTime = 0;
const COOLDOWN_MS = 1000;
button.addEventListener('click', async (e) => {
e.preventDefault();
e.stopPropagation();
// Rate limiting
const now = Date.now();
if (now - lastInsertTime < COOLDOWN_MS || isInserting) {
return;
}
if (!contextUrl) {
alert('No context URL set. Click the Context Bridge extension icon to configure.');
return;
}
// Loading state
isInserting = true;
button.disabled = true;
button.classList.add('loading');
button.innerHTML = `
<svg class="context-bridge-icon spinning" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 12a9 9 0 1 1-6.219-8.56"/>
</svg>
<span>Inserting...</span>
`;
try {
// Verify context is accessible
const response = await fetch(contextUrl);
if (!response.ok) {
throw new Error(`Failed to fetch context (HTTP ${response.status})`);
}
// Insert context message
const message = `Read ${contextUrl} first, then help me with: `;
// Set textarea value
textarea.value = message;
textarea.focus();
// Trigger input event so ChatGPT recognizes the change
const inputEvent = new Event('input', { bubbles: true });
textarea.dispatchEvent(inputEvent);
// Position cursor at end
textarea.setSelectionRange(message.length, message.length);
// Success state
lastInsertTime = now;
button.classList.remove('loading');
button.classList.add('injected');
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="20 6 9 17 4 12"/>
</svg>
<span>Context Inserted ✓</span>
`;
// Reset after 2 seconds
setTimeout(() => {
button.classList.remove('injected');
button.disabled = false;
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
<div class="context-bridge-tooltip">Click to insert your context</div>
`;
isInserting = false;
}, 2000);
} catch (error) {
// Error state
console.error('Context Bridge error:', error);
button.classList.remove('loading');
button.classList.add('error');
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<line x1="15" y1="9" x2="9" y2="15"/>
<line x1="9" y1="9" x2="15" y2="15"/>
</svg>
<span>Failed</span>
`;
alert(`Failed to insert context:\n\n${error.message}\n\nPlease check:\n1. Context URL is accessible\n2. You're connected to the internet\n3. Try refreshing the page`);
setTimeout(() => {
button.classList.remove('error');
button.disabled = false;
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
<div class="context-bridge-tooltip">Click to insert your context</div>
`;
isInserting = false;
}, 3000);
}
});
// Add button to the form
formContainer.style.position = 'relative';
formContainer.appendChild(button);
console.log('Context Bridge: Button injected on ChatGPT');
}
function updateButton() {
const button = document.querySelector('.context-bridge-button');
if (!button) {
if (contextUrl) {
injectButton();
}
}
}
// Watch for DOM changes (ChatGPT is a SPA)
const observer = new MutationObserver((mutations) => {
if (!document.querySelector('.context-bridge-button') && contextUrl) {
injectButton();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
// Initial injection
if (contextUrl) {
injectButton();
}

View File

@@ -0,0 +1,265 @@
/**
* Context Bridge - Improved Claude Content Script with Caching & Cleanup
*/
console.log('Context Bridge: Loaded on Claude.ai');
let contextUrl = null;
let isInjected = false;
let lastInsertTime = 0;
let isInserting = false;
const COOLDOWN_MS = 1000;
// Simple in-memory cache with 5-minute TTL
const cache = {
data: null,
url: null,
timestamp: null,
TTL: 5 * 60 * 1000, // 5 minutes
get(url) {
if (this.url !== url) return null;
if (!this.timestamp) return null;
if (Date.now() - this.timestamp > this.TTL) {
this.clear();
return null;
}
return this.data;
},
set(url, data) {
this.url = url;
this.data = data;
this.timestamp = Date.now();
},
clear() {
this.data = null;
this.url = null;
this.timestamp = null;
}
};
// Get context URL from storage
chrome.runtime.sendMessage({ action: 'getContextUrl' }, (response) => {
if (response && response.rawUrl) {
contextUrl = response.rawUrl;
injectButton();
}
});
// Listen for storage changes
chrome.storage.onChanged.addListener((changes, namespace) => {
if (namespace === 'sync' && changes.rawUrl) {
contextUrl = changes.rawUrl.newValue;
cache.clear(); // Clear cache when URL changes
updateButton();
}
});
function injectButton() {
// Find the input area (Claude uses a contenteditable div)
const inputArea = document.querySelector('[contenteditable="true"]');
if (!inputArea) {
// Retry in 500ms if input not found yet
setTimeout(injectButton, 500);
return;
}
// Check if button already exists
if (document.querySelector('.context-bridge-button')) {
return;
}
// Find the parent container
const inputContainer = inputArea.closest('div[class*="relative"]') || inputArea.parentElement;
if (!inputContainer) {
return;
}
// Create button
const button = document.createElement('button');
button.className = 'context-bridge-button';
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
<div class="context-bridge-tooltip">Click to insert your context</div>
`;
// Add click handler with caching
button.addEventListener('click', async (e) => {
e.preventDefault();
e.stopPropagation();
// Rate limiting
const now = Date.now();
if (now - lastInsertTime < COOLDOWN_MS || isInserting) {
return;
}
if (!contextUrl) {
alert('No context URL set. Click the Context Bridge extension icon to configure.');
return;
}
// Loading state
isInserting = true;
button.disabled = true;
button.classList.add('loading');
button.innerHTML = `
<svg class="context-bridge-icon spinning" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 12a9 9 0 1 1-6.219-8.56"/>
</svg>
<span>Inserting...</span>
`;
try {
// Check cache first
let contextContent = cache.get(contextUrl);
if (!contextContent) {
// Cache miss - fetch from network
const response = await fetch(contextUrl);
if (!response.ok) {
throw new Error(`Failed to fetch context (HTTP ${response.status})`);
}
contextContent = await response.text();
// Store in cache
cache.set(contextUrl, contextContent);
}
// Insert context message
const message = `Read ${contextUrl} first, then help me with: `;
// Insert into Claude's input
inputArea.focus();
// Try modern approach first
if (inputArea.isContentEditable) {
const selection = window.getSelection();
const range = document.createRange();
range.selectNodeContents(inputArea);
range.collapse(false);
selection.removeAllRanges();
selection.addRange(range);
const textNode = document.createTextNode(message);
range.insertNode(textNode);
range.setStartAfter(textNode);
range.collapse(true);
selection.removeAllRanges();
selection.addRange(range);
} else {
// Fallback for textarea
inputArea.value = message + (inputArea.value || '');
inputArea.setSelectionRange(message.length, message.length);
}
// Success state
lastInsertTime = now;
button.classList.remove('loading');
button.classList.add('injected');
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="20 6 9 17 4 12"/>
</svg>
<span>Context Inserted ✓</span>
`;
// Reset after 2 seconds
setTimeout(() => {
button.classList.remove('injected');
button.disabled = false;
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
<div class="context-bridge-tooltip">Click to insert your context</div>
`;
isInserting = false;
}, 2000);
} catch (error) {
// Error state
console.error('Context Bridge error:', error);
button.classList.remove('loading');
button.classList.add('error');
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<line x1="15" y1="9" x2="9" y2="15"/>
<line x1="9" y1="9" x2="15" y2="15"/>
</svg>
<span>Failed to load</span>
`;
alert(`Failed to insert context:\n\n${error.message}\n\nPlease check:\n1. Context URL is accessible\n2. You're connected to the internet\n3. Try refreshing the page`);
// Reset button
setTimeout(() => {
button.classList.remove('error');
button.disabled = false;
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
<div class="context-bridge-tooltip">Click to insert your context</div>
`;
isInserting = false;
}, 3000);
}
});
// Add button to the DOM
const sendButton = inputContainer.querySelector('button[aria-label*="Send"]') ||
inputContainer.querySelector('button[type="submit"]');
if (sendButton && sendButton.parentElement) {
sendButton.parentElement.insertBefore(button, sendButton);
} else {
inputContainer.appendChild(button);
}
console.log('Context Bridge: Button injected on Claude.ai');
}
function updateButton() {
const button = document.querySelector('.context-bridge-button');
if (!button) {
if (contextUrl) {
injectButton();
}
}
}
// Watch for DOM changes (Claude is a SPA)
const observer = new MutationObserver((mutations) => {
if (!document.querySelector('.context-bridge-button') && contextUrl) {
injectButton();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
// Cleanup on page unload
window.addEventListener('beforeunload', () => {
observer.disconnect();
cache.clear();
});
// Initial injection
if (contextUrl) {
injectButton();
}

View File

@@ -0,0 +1,229 @@
/**
* Context Bridge - Claude.ai Content Script
* Injects "Insert Context" button into Claude chat interface
*/
console.log('Context Bridge: Loaded on Claude.ai');
let contextUrl = null;
let isInjected = false;
// Get context URL from storage
chrome.runtime.sendMessage({ action: 'getContextUrl' }, (response) => {
if (response && response.rawUrl) {
contextUrl = response.rawUrl;
injectButton();
}
});
// Listen for storage changes
chrome.storage.onChanged.addListener((changes, namespace) => {
if (namespace === 'sync' && changes.rawUrl) {
contextUrl = changes.rawUrl.newValue;
updateButton();
}
});
function injectButton() {
// Find the input area (Claude uses a contenteditable div)
const inputArea = document.querySelector('[contenteditable="true"]');
if (!inputArea) {
// Retry in 500ms if input not found yet
setTimeout(injectButton, 500);
return;
}
// Check if button already exists
if (document.querySelector('.context-bridge-button')) {
return;
}
// Find the parent container
const inputContainer = inputArea.closest('div[class*="relative"]') || inputArea.parentElement;
if (!inputContainer) {
return;
}
// Create button
const button = document.createElement('button');
button.className = 'context-bridge-button';
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
<div class="context-bridge-tooltip">Click to insert your context</div>
`;
// Add click handler
let isInserting = false;
let lastInsertTime = 0;
const COOLDOWN_MS = 1000; // 1 second cooldown
button.addEventListener('click', async (e) => {
e.preventDefault();
e.stopPropagation();
// Rate limiting
const now = Date.now();
if (now - lastInsertTime < COOLDOWN_MS) {
return; // Too soon, ignore click
}
// Prevent double-click
if (isInserting) {
return;
}
if (!contextUrl) {
alert('No context URL set. Click the Context Bridge extension icon to configure.');
return;
}
// Show loading state
isInserting = true;
button.disabled = true;
button.classList.add('loading');
button.innerHTML = `
<svg class="context-bridge-icon spinning" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 12a9 9 0 1 1-6.219-8.56"/>
</svg>
<span>Inserting...</span>
`;
try {
// Fetch context to verify it's accessible
const response = await fetch(contextUrl);
if (!response.ok) {
throw new Error(`Failed to fetch context (HTTP ${response.status})`);
}
// Insert context message
const message = `Read ${contextUrl} first, then help me with: `;
// Insert into Claude's input
inputArea.focus();
// Try modern approach first
if (inputArea.isContentEditable) {
const selection = window.getSelection();
const range = document.createRange();
range.selectNodeContents(inputArea);
range.collapse(false);
selection.removeAllRanges();
selection.addRange(range);
// Try to insert text
const textNode = document.createTextNode(message);
range.insertNode(textNode);
range.setStartAfter(textNode);
range.collapse(true);
selection.removeAllRanges();
selection.addRange(range);
} else {
// Fallback for textarea
inputArea.value = message + inputArea.value;
inputArea.setSelectionRange(message.length, message.length);
}
// Success state
lastInsertTime = now;
button.classList.remove('loading');
button.classList.add('injected');
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="20 6 9 17 4 12"/>
</svg>
<span>Context Inserted ✓</span>
`;
// Reset after 2 seconds
setTimeout(() => {
button.classList.remove('injected');
button.disabled = false;
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
<div class="context-bridge-tooltip">Click to insert your context</div>
`;
isInserting = false;
}, 2000);
} catch (error) {
// Error state
console.error('Context Bridge error:', error);
button.classList.remove('loading');
button.classList.add('error');
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<line x1="15" y1="9" x2="9" y2="15"/>
<line x1="9" y1="9" x2="15" y2="15"/>
</svg>
<span>Failed to load</span>
`;
alert(`Failed to insert context:\n\n${error.message}\n\nPlease check:\n1. Context URL is accessible\n2. You're connected to the internet\n3. Try refreshing the page`);
// Reset button
setTimeout(() => {
button.classList.remove('error');
button.disabled = false;
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
<div class="context-bridge-tooltip">Click to insert your context</div>
`;
isInserting = false;
}, 3000);
}
});
// Add button to the DOM
// Try to place it near the send button
const sendButton = inputContainer.querySelector('button[aria-label*="Send"]') ||
inputContainer.querySelector('button[type="submit"]');
if (sendButton && sendButton.parentElement) {
sendButton.parentElement.insertBefore(button, sendButton);
} else {
// Fallback: add to input container
inputContainer.appendChild(button);
}
console.log('Context Bridge: Button injected on Claude.ai');
}
function updateButton() {
const button = document.querySelector('.context-bridge-button');
if (!button) {
if (contextUrl) {
injectButton();
}
}
}
// Watch for DOM changes (Claude is a SPA)
const observer = new MutationObserver((mutations) => {
if (!document.querySelector('.context-bridge-button') && contextUrl) {
injectButton();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
// Initial injection
if (contextUrl) {
injectButton();
}

View File

@@ -0,0 +1,76 @@
// This is a template showing the improved pattern
// Apply to: chatgpt.js, copilot.js, gemini.js
// Key improvements to apply:
// 1. Rate limiting with cooldown
// 2. Loading/success/error states
// 3. Fetch context before inserting
// 4. Better error messages
// 5. Disabled state during operation
const COOLDOWN_MS = 1000;
let isInserting = false;
let lastInsertTime = 0;
button.addEventListener('click', async (e) => {
e.preventDefault();
e.stopPropagation();
// Rate limiting
const now = Date.now();
if (now - lastInsertTime < COOLDOWN_MS || isInserting) {
return;
}
if (!contextUrl) {
alert('No context URL set. Click the Context Bridge extension icon to configure.');
return;
}
// Loading state
isInserting = true;
button.disabled = true;
button.classList.add('loading');
button.innerHTML = `<svg class="context-bridge-icon spinning" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12a9 9 1 1-6.219-8.56"/></svg><span>Inserting...</span>`;
try {
// Verify context is accessible
const response = await fetch(contextUrl);
if (!response.ok) {
throw new Error(`Failed to fetch context (HTTP ${response.status})`);
}
// Insert message
const message = `Read ${contextUrl} first, then help me with: `;
inputArea.focus();
inputArea.value = message + (inputArea.value || '');
inputArea.setSelectionRange(message.length, message.length);
// Success state
lastInsertTime = now;
button.classList.remove('loading');
button.classList.add('injected');
button.innerHTML = `<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg><span>Context Inserted ✓</span>`;
setTimeout(() => {
button.classList.remove('injected');
button.disabled = false;
button.innerHTML = originalButtonHTML;
isInserting = false;
}, 2000);
} catch (error) {
// Error state
console.error('Context Bridge error:', error);
button.classList.remove('loading');
button.classList.add('error');
button.innerHTML = `<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg><span>Failed</span>`;
alert(`Failed to insert context:\n\n${error.message}\n\nPlease check:\n1. Context URL is accessible\n2. You're connected to the internet\n3. Try refreshing the page`);
setTimeout(() => {
button.classList.remove('error');
button.disabled = false;
button.innerHTML = originalButtonHTML;
isInserting = false;
}, 3000);
}
});

View File

@@ -0,0 +1,71 @@
/**
* Context Bridge - Microsoft Copilot Content Script
*/
console.log('Context Bridge: Loaded on Microsoft Copilot');
let contextUrl = null;
chrome.runtime.sendMessage({ action: 'getContextUrl' }, (response) => {
if (response && response.rawUrl) {
contextUrl = response.rawUrl;
injectButton();
}
});
chrome.storage.onChanged.addListener((changes, namespace) => {
if (namespace === 'sync' && changes.rawUrl) {
contextUrl = changes.rawUrl.newValue;
}
});
function injectButton() {
const textarea = document.querySelector('textarea') ||
document.querySelector('[contenteditable="true"]');
if (!textarea) {
setTimeout(injectButton, 500);
return;
}
if (document.querySelector('.context-bridge-button')) {
return;
}
const button = document.createElement('button');
button.type = 'button';
button.className = 'context-bridge-button';
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
`;
button.addEventListener('click', (e) => {
e.preventDefault();
if (!contextUrl) {
alert('No context URL set. Click the Context Bridge extension icon to configure.');
return;
}
const message = `Read ${contextUrl} first, then help me with: `;
textarea.value = message;
textarea.focus();
});
textarea.parentElement.appendChild(button);
console.log('Context Bridge: Button injected on Copilot');
}
const observer = new MutationObserver(() => {
if (!document.querySelector('.context-bridge-button') && contextUrl) {
injectButton();
}
});
observer.observe(document.body, { childList: true, subtree: true });
if (contextUrl) {
injectButton();
}

View File

@@ -0,0 +1,71 @@
/**
* Context Bridge - Google Gemini Content Script
*/
console.log('Context Bridge: Loaded on Google Gemini');
let contextUrl = null;
chrome.runtime.sendMessage({ action: 'getContextUrl' }, (response) => {
if (response && response.rawUrl) {
contextUrl = response.rawUrl;
injectButton();
}
});
chrome.storage.onChanged.addListener((changes, namespace) => {
if (namespace === 'sync' && changes.rawUrl) {
contextUrl = changes.rawUrl.newValue;
}
});
function injectButton() {
const textarea = document.querySelector('textarea') ||
document.querySelector('[contenteditable="true"]');
if (!textarea) {
setTimeout(injectButton, 500);
return;
}
if (document.querySelector('.context-bridge-button')) {
return;
}
const button = document.createElement('button');
button.type = 'button';
button.className = 'context-bridge-button';
button.innerHTML = `
<svg class="context-bridge-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
<polyline points="13 2 13 9 20 9"/>
</svg>
<span>Insert Context</span>
`;
button.addEventListener('click', (e) => {
e.preventDefault();
if (!contextUrl) {
alert('No context URL set. Click the Context Bridge extension icon to configure.');
return;
}
const message = `Read ${contextUrl} first, then help me with: `;
textarea.value = message;
textarea.focus();
});
textarea.parentElement.appendChild(button);
console.log('Context Bridge: Button injected on Gemini');
}
const observer = new MutationObserver(() => {
if (!document.querySelector('.context-bridge-button') && contextUrl) {
injectButton();
}
});
observer.observe(document.body, { childList: true, subtree: true });
if (contextUrl) {
injectButton();
}

View File

@@ -0,0 +1,176 @@
/* Context Bridge - Injection Button Styles */
.context-bridge-button {
position: relative;
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 12px;
background: linear-gradient(135deg, #F5A623 0%, #FF1D6C 38.2%, #9C27B0 61.8%, #2979FF 100%);
color: white;
border: none;
border-radius: 6px;
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
z-index: 9999;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.context-bridge-button:hover:not(:disabled) {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.context-bridge-button:active:not(:disabled) {
transform: translateY(0);
}
.context-bridge-button:disabled {
opacity: 0.7;
cursor: not-allowed;
}
.context-bridge-button.injected {
background: #10B981;
}
.context-bridge-button.error {
background: #EF4444;
}
.context-bridge-button.loading {
background: #667eea;
}
.context-bridge-icon {
width: 16px;
height: 16px;
}
.context-bridge-icon.spinning {
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Tooltip */
.context-bridge-tooltip {
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
margin-bottom: 8px;
padding: 8px 12px;
background: rgba(0, 0, 0, 0.9);
color: white;
border-radius: 6px;
font-size: 12px;
white-space: nowrap;
opacity: 0;
pointer-events: none;
transition: opacity 0.2s ease;
z-index: 10000;
}
.context-bridge-button:hover:not(:disabled) .context-bridge-tooltip {
opacity: 1;
}
/* Preview popup */
.context-bridge-preview {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: 600px;
max-height: 80vh;
background: white;
border-radius: 12px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
z-index: 10001;
overflow: hidden;
display: none;
}
.context-bridge-preview.show {
display: flex;
flex-direction: column;
}
.context-bridge-preview-header {
padding: 16px 20px;
background: linear-gradient(135deg, #F5A623 0%, #FF1D6C 38.2%, #9C27B0 61.8%, #2979FF 100%);
color: white;
display: flex;
justify-content: space-between;
align-items: center;
}
.context-bridge-preview-title {
font-size: 16px;
font-weight: 600;
}
.context-bridge-preview-close {
background: rgba(255, 255, 255, 0.2);
border: none;
color: white;
width: 28px;
height: 28px;
border-radius: 50%;
cursor: pointer;
font-size: 18px;
line-height: 1;
transition: background 0.2s;
}
.context-bridge-preview-close:hover {
background: rgba(255, 255, 255, 0.3);
}
.context-bridge-preview-content {
padding: 20px;
overflow-y: auto;
flex: 1;
font-size: 14px;
line-height: 1.6;
color: #333;
}
.context-bridge-preview-content pre {
background: #f5f5f5;
padding: 12px;
border-radius: 6px;
overflow-x: auto;
font-size: 13px;
}
.context-bridge-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 10000;
display: none;
}
.context-bridge-overlay.show {
display: block;
}
/* Loading spinner */
.context-bridge-spinner {
display: inline-block;
width: 14px;
height: 14px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: white;
animation: spin 0.6s linear infinite;
}