diff --git a/package-lock.json b/package-lock.json index a9af8c9..6d114bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lakera", - "version": "0.1.0", + "version": "0.1.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lakera", - "version": "0.1.0", + "version": "0.1.5", "hasInstallScript": true, "dependencies": { "addresser": "^1.1.20", diff --git a/package.json b/package.json index ecb0b50..e89496c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lakera", - "version": "0.1.4", + "version": "0.1.5", "description": "Lakera - ChatGPT Data Leak Protection", "scripts": { "dev": "vite build --watch", diff --git a/public/manifest.json b/public/manifest.json index 022b24c..3a1a44a 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Lakera - ChatGPT Data Leak Protection", "description": "Lakera Chrome Extension provides a privacy guard that protects you against sharing sensitive information with ChatGPT.", - "version": "0.1.4", + "version": "0.1.5", "action": { "default_icon": "icon-19.png", "default_popup": "src/popup/popup.html" @@ -16,7 +16,7 @@ }, "content_scripts": [ { - "matches": ["https://chat.openai.com/*"], + "matches": ["https://chat.openai.com/*", "https://chatgpt.com/*"], "js": ["src/content.js"] } ], @@ -26,7 +26,7 @@ "web_accessible_resources": [ { "resources": ["icon-128.png"], - "matches": ["https://chat.openai.com/*"] + "matches": ["https://chat.openai.com/*", "https://chatgpt.com/*"] } ], "permissions": [ diff --git a/src/content.ts b/src/content.ts index b8a169d..bf192cd 100644 --- a/src/content.ts +++ b/src/content.ts @@ -20,7 +20,7 @@ async function fetchDomElements (): Promise { 'prompt-textarea' ) as HTMLTextAreaElement | null const button: HTMLButtonElement | null = - textarea?.parentElement?.querySelector('button') ?? null + textarea?.parentElement?.parentElement?.querySelector(':scope > button') ?? null if (textarea !== null && button !== null) { return { textarea, button } @@ -95,7 +95,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { async function fetchButton (textarea: HTMLTextAreaElement | null): Promise { const button: HTMLButtonElement | null = - textarea?.parentElement?.querySelector('button') ?? null + textarea?.parentElement?.parentElement?.querySelector(':scope > button') ?? null if (button !== null) { return button @@ -109,6 +109,7 @@ function addEventListenersToButton (textarea: HTMLTextAreaElement | null, button button?.addEventListener('click', (event) => { void (async () => { if (event.isTrusted) { + event.stopPropagation() event.preventDefault() const proceed = await shouldProceed(textarea) if (proceed) { @@ -155,6 +156,7 @@ function addEventListeners ( button?.addEventListener('click', (event) => { void (async () => { if (event.isTrusted) { + event.stopPropagation() event.preventDefault() const proceed = await shouldProceed(textarea) if (proceed) { diff --git a/src/popup/popup.ts b/src/popup/popup.ts index 2dd6039..00450dc 100644 --- a/src/popup/popup.ts +++ b/src/popup/popup.ts @@ -1,4 +1,4 @@ -import { TIMEOUT_ADD_CLASS, CHATGPT_URL } from './popup_config' +import { TIMEOUT_ADD_CLASS, CHAT_GPT_URLS } from './popup_config' function addEventListenersToToggles (detectorToggles: NodeListOf): void { for (const detector of detectorToggles) { @@ -23,7 +23,7 @@ async function addTriggeredDetectorsToDom (): Promise { if ( tab.id !== undefined && tab.url !== undefined && - tab.url.includes(CHATGPT_URL) + CHAT_GPT_URLS.some(CHAT_GPT_URL => tab.url?.includes(CHAT_GPT_URL)) ) { chrome.tabs.sendMessage( tab.id, diff --git a/src/popup/popup_config.ts b/src/popup/popup_config.ts index 73fdf9e..c22e3b3 100644 --- a/src/popup/popup_config.ts +++ b/src/popup/popup_config.ts @@ -1,2 +1,2 @@ -export const CHATGPT_URL = 'chat.openai.com' +export const CHAT_GPT_URLS = ['chat.openai.com', 'chatgpt.com'] export const TIMEOUT_ADD_CLASS = 1000