-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentScript.js
More file actions
23 lines (21 loc) · 814 Bytes
/
Copy pathcontentScript.js
File metadata and controls
23 lines (21 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Listen for messages from the web page
window.addEventListener('message', async (event) => {
// Verify the origin
if (event.origin !== 'http://localhost:5173' && event.origin !== 'https://your-production-url.com') {
return;
}
if (event.data.type === 'TWITTER_BOOKMARK_AUTH') {
const { token, userEmail, profilePictureUrl } = event.data.data;
if (token && userEmail) {
await chrome.storage.local.set({
token,
userEmail,
profilePictureUrl: profilePictureUrl || null
});
console.log('categoriX: Auth data synced to extension');
}
} else if (event.data.type === 'TWITTER_BOOKMARK_LOGOUT') {
await chrome.storage.local.remove(['token', 'userEmail', 'profilePictureUrl']);
console.log('categoriX: Logged out from extension');
}
});