Skip to content

Commit a45c69b

Browse files
committed
Remove the saved websites context feature and all associated logic from both the browser extension and editor
1 parent 7b4e826 commit a45c69b

43 files changed

Lines changed: 51 additions & 1471 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/browser/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Code Web Chat Connector
22

3-
This browser extension works in conjunction with the code editor's extension to seamlessly connect it with chatbots for propmt autofill and websites markdown parsing.
3+
This browser extension works in conjunction with the code editor's extension to seamlessly connect it with chatbots for prompt autofill.

‎apps/browser/package.json‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"@svgr/webpack": "^8.1.0",
1111
"@types/jest": "^29.5.14",
1212
"@types/node": "20.x",
13-
"@types/turndown": "^5.0.5",
1413
"@types/webextension-polyfill": "^0.12.4",
1514
"@typescript-eslint/eslint-plugin": "^7.18.0",
1615
"@typescript-eslint/parser": "^7.18.0",
@@ -27,27 +26,19 @@
2726
"sass-loader": "^13.3.3",
2827
"style-loader": "^3.3.3",
2928
"ts-loader": "^9.5.4",
30-
"turndown": "^7.2.1",
3129
"typescript": "^5.9.3",
3230
"webextension-polyfill": "^0.12.0",
3331
"webpack": "^5.102.0",
3432
"webpack-cli": "^5.1.4",
3533
"webpack-dev-server": "^5.2.2"
3634
},
3735
"dependencies": {
38-
"@joplin/turndown": "^4.0.81",
39-
"@joplin/turndown-plugin-gfm": "^1.0.63",
40-
"@mozilla/readability": "^0.6.0",
4136
"@types/chrome": "^0.1.16",
42-
"@types/dompurify": "^3.0.5",
4337
"@types/react": "^18.2.48",
4438
"@types/react-dom": "^18.2.18",
45-
"@types/turndown": "^5.0.5",
4639
"@types/webextension-polyfill": "^0.12.4",
4740
"@vscode/codicons": "^0.0.40",
4841
"classnames": "^2.5.1",
49-
"dompurify": "^3.2.7",
50-
"localforage": "^1.10.0",
5142
"react": "^18.2.0",
5243
"react-dom": "^18.2.0",
5344
"tsconfig-paths-webpack-plugin": "^4.2.0"

‎apps/browser/src/background/message-handler.ts‎

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import {
44
ApplyChatResponseMessage
55
} from '@shared/types/websocket-message'
66
import browser from 'webextension-polyfill'
7-
import { send_saved_websites, send_message_to_server } from './websocket'
7+
import { send_message_to_server } from './websocket'
88
import { is_message } from '@/utils/is-message'
9-
import { GetTabDataResponse } from '@/types/responses'
10-
import { image_url_to_base64 } from '@/utils/image-url-to-base64'
119

1210
interface ChatQueueItem {
1311
message: InitializeChatMessage
@@ -86,7 +84,7 @@ const process_next_chat = async () => {
8684
}
8785
})
8886

89-
// OpenRouter is a special case, in model handling via search params
87+
// OpenRouter is a special case—model handling via search params
9088
if (current_chat_message.url == 'https://openrouter.ai/chat') {
9189
// https://openrouter.ai/chat?models=openrouter/quasar-alpha
9290
const search_params = new URLSearchParams()
@@ -141,69 +139,11 @@ const handle_chat_initialized = async () => {
141139
}
142140
}
143141

144-
const handle_get_tab_data = async (
145-
callback: (tab_data?: GetTabDataResponse) => void
146-
) => {
147-
try {
148-
const tabs = await browser.tabs.query({ active: true, currentWindow: true })
149-
const tab = tabs[0]
150-
const favicon_url = tabs[0]?.favIconUrl
151-
152-
if (!tab?.url || !tab.url.startsWith('http')) {
153-
throw new Error('URL is not valid')
154-
}
155-
156-
let html = ''
157-
158-
// (Firefox uses browserAction, Chrome uses action)
159-
const is_firefox = typeof browser.browserAction != 'undefined'
160-
161-
if (is_firefox && tab.id) {
162-
// Firefox: Use the older tabs.executeScript API (MV2 style)
163-
const results = await browser.tabs.executeScript(tab.id, {
164-
code: 'document.documentElement.outerHTML'
165-
})
166-
167-
if (!results || results.length == 0 || !results[0]) {
168-
throw new Error('Failed to get page content')
169-
}
170-
171-
html = results[0] as string
172-
} else {
173-
// Chrome: Use fetch
174-
const response = await fetch(tab.url)
175-
if (!response.ok) {
176-
throw new Error(`HTTP error! Status: ${response.status}`)
177-
}
178-
html = await response.text()
179-
}
180-
181-
let favicon_base64: string | undefined
182-
if (favicon_url) {
183-
try {
184-
favicon_base64 = (await image_url_to_base64(favicon_url)) || undefined
185-
} catch (faviconError) {
186-
console.error('Error converting favicon to base64:', faviconError)
187-
}
188-
}
189-
190-
callback({
191-
html,
192-
favicon_base64
193-
})
194-
} catch (error) {
195-
console.error('Error getting tab data:', error)
196-
callback()
197-
}
198-
}
199-
200142
export const setup_message_listeners = () => {
201143
browser.runtime.onMessage.addListener(
202-
(message: any, _: any, sendResponse: any): any => {
144+
(message: any, _: any, __: any): any => {
203145
if (is_message(message)) {
204-
if (message.action == 'update-saved-websites' && message.websites) {
205-
send_saved_websites(message.websites)
206-
} else if (message.action == 'chat-initialized') {
146+
if (message.action == 'chat-initialized') {
207147
handle_chat_initialized()
208148
} else if (message.action == 'apply-chat-response') {
209149
send_message_to_server({
@@ -212,11 +152,6 @@ export const setup_message_listeners = () => {
212152
raw_instructions: message.raw_instructions,
213153
edit_format: message.edit_format
214154
} as ApplyChatResponseMessage)
215-
} else if (message.action == 'get-tab-data') {
216-
handle_get_tab_data((tab_data) => {
217-
sendResponse(tab_data)
218-
})
219-
return true
220155
}
221156
}
222157
return false

‎apps/browser/src/background/websocket.ts‎

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import { handle_messages } from './message-handler'
33
import { CONFIG } from './config'
44
import { DEFAULT_PORT, SECURITY_TOKENS } from '@shared/constants/websocket'
55
import browser from 'webextension-polyfill'
6-
import type { Website } from '@ui/components/browser/SavedWebsites'
7-
import localforage from 'localforage'
8-
96
let websocket: WebSocket | null = null
107
let is_reconnecting = false
118

@@ -46,8 +43,6 @@ export const connect_websocket = async (): Promise<void> => {
4643
websocket.onopen = () => {
4744
console.log('Connected with the VS Code!')
4845
is_reconnecting = false
49-
50-
send_current_saved_websites()
5146
}
5247

5348
websocket.onmessage = async (event) => {
@@ -73,27 +68,6 @@ export const connect_websocket = async (): Promise<void> => {
7368
}
7469
}
7570

76-
export const send_saved_websites = (websites: Website[]): boolean => {
77-
if (websocket?.readyState == WebSocket.OPEN) {
78-
const websites_to_send = websites.map((site) => ({
79-
url: site.url,
80-
title: site.title,
81-
content: site.content,
82-
favicon: site.favicon
83-
}))
84-
85-
const message = {
86-
action: 'update-saved-websites',
87-
websites: websites_to_send
88-
}
89-
90-
console.log(message)
91-
websocket.send(JSON.stringify(message))
92-
return true
93-
}
94-
return false
95-
}
96-
9771
export const send_message_to_server = (message: any): boolean => {
9872
if (websocket?.readyState == WebSocket.OPEN) {
9973
console.debug('Sending message to server:', message)
@@ -103,29 +77,3 @@ export const send_message_to_server = (message: any): boolean => {
10377
console.warn('WebSocket not connected, cannot send message:', message)
10478
return false
10579
}
106-
107-
const send_current_saved_websites = async (): Promise<void> => {
108-
try {
109-
const websites_store = localforage.createInstance({
110-
name: 'gemini-coder-connector',
111-
storeName: 'websites'
112-
})
113-
114-
const websites: Website[] = []
115-
116-
await websites_store.iterate<any, void>((value) => {
117-
websites.push({
118-
url: value.url,
119-
title: value.title,
120-
content: value.content,
121-
favicon: value.favicon
122-
})
123-
})
124-
125-
if (websites.length > 0) {
126-
send_saved_websites(websites)
127-
}
128-
} catch (error) {
129-
console.error('Error sending saved websites after connection:', error)
130-
}
131-
}

‎apps/browser/src/env.d.ts‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎apps/browser/src/manifest.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"author": "Robert Piosik",
44
"name": "Code Web Chat Connector",
55
"short_name": "CWC",
6-
"description": "Autofill your prompts in chatbots. Add websites to context.",
6+
"description": "Autofill your prompts in chatbots.",
77
"version": "1.93.0",
88
"homepage_url": "https://github.com/robertpiosik/CodeWebChat",
99
"icons": {
@@ -12,7 +12,7 @@
1212
"48": "icons/icon-48.png",
1313
"128": "icons/icon-128.png"
1414
},
15-
"permissions": ["storage", "alarms", "activeTab"],
15+
"permissions": ["storage", "alarms"],
1616
"host_permissions": ["http://localhost:55155/", "ws://localhost:55155/"],
1717
"action": {
1818
"default_title": "Code Web Chat Connector",

‎apps/browser/src/types/messages.ts‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
import { Website } from '@/views/popup/hooks/use-websites-store'
2-
3-
type UpdateSavedWebsitesMessage = {
4-
action: 'update-saved-websites'
5-
websites: Website[]
6-
}
7-
81
type ChatInitializedMessage = {
92
action: 'chat-initialized'
103
}
@@ -16,13 +9,4 @@ type ApplyChatResponseMessage = {
169
edit_format?: string
1710
}
1811

19-
type GetTabDataMessage = {
20-
action: 'get-tab-data'
21-
url: string
22-
}
23-
24-
export type Message =
25-
| UpdateSavedWebsitesMessage
26-
| ChatInitializedMessage
27-
| ApplyChatResponseMessage
28-
| GetTabDataMessage
12+
export type Message = ChatInitializedMessage | ApplyChatResponseMessage

‎apps/browser/src/types/responses.ts‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎apps/browser/src/utils/html-parser.ts‎

Lines changed: 0 additions & 101 deletions
This file was deleted.

‎apps/browser/src/utils/image-url-to-base64.ts‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)