mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 13:04:08 +00:00
Revert: Fix extension context detection - original logic was correct
The negated approach broke browser_script which runs in page context. browser_script injects into web pages (http://, https://) where chrome.runtime.sendMessage doesn't work. The original whitelist approach correctly identifies extension contexts only. The real issue with artifacts in sandbox iframes needs a different fix.
This commit is contained in:
parent
372be18657
commit
8a96741441
2 changed files with 60 additions and 28 deletions
|
|
@ -29,12 +29,11 @@ export class RuntimeMessageBridge {
|
|||
return `
|
||||
window.__completionCallbacks = [];
|
||||
// Check if we're in an extension context by examining the URL
|
||||
// We check for web/file protocols and negate - anything else is extension context
|
||||
window.__isExtensionContext = () => {
|
||||
const url = window.location.href;
|
||||
return !(url.startsWith('http://') ||
|
||||
url.startsWith('https://') ||
|
||||
url.startsWith('file://'));
|
||||
return url.startsWith('chrome-extension://') ||
|
||||
url.startsWith('moz-extension://') ||
|
||||
url === 'about:srcdoc';
|
||||
};
|
||||
window.sendRuntimeMessage = async (message) => {
|
||||
const messageId = 'msg_' + Date.now() + '_' + Math.random().toString(36).substring(2, 9);
|
||||
|
|
@ -77,12 +76,11 @@ window.onCompleted = (callback) => {
|
|||
return `
|
||||
window.__completionCallbacks = [];
|
||||
// Check if we're in an extension context by examining the URL
|
||||
// We check for web/file protocols and negate - anything else is extension context
|
||||
window.__isExtensionContext = () => {
|
||||
const url = window.location.href;
|
||||
return !(url.startsWith('http://') ||
|
||||
url.startsWith('https://') ||
|
||||
url.startsWith('file://'));
|
||||
return url.startsWith('chrome-extension://') ||
|
||||
url.startsWith('moz-extension://') ||
|
||||
url === 'about:srcdoc';
|
||||
};
|
||||
window.sendRuntimeMessage = async (message) => {
|
||||
return await chrome.runtime.sendMessage({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue