-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathbackground.js
More file actions
33 lines (31 loc) · 1.07 KB
/
Copy pathbackground.js
File metadata and controls
33 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Handle extension installation
chrome.runtime.onInstalled.addListener(() => {
console.log('Claude Conversation Exporter installed');
});
// Inject content script into already-open Claude.ai tabs when extension is installed/updated
chrome.runtime.onInstalled.addListener(() => {
chrome.tabs.query({ url: 'https://claude.ai/*' }, (tabs) => {
tabs.forEach(tab => {
chrome.scripting.executeScript({
target: { tabId: tab.id },
files: ['content.js']
}).catch(err => console.log('Could not inject into tab', tab.id, err));
});
});
});
// Handle messages from popup when content script might not be injected
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'ensureContentScript') {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (tabs[0]) {
chrome.scripting.executeScript({
target: { tabId: tabs[0].id },
files: ['content.js']
}, () => {
sendResponse({ success: true });
});
}
});
return true;
}
});