99 lines
No EOL
3.6 KiB
JavaScript
99 lines
No EOL
3.6 KiB
JavaScript
// Platform Detector Module
|
|
// Detects whether we're on Gmail or Instantly.ai and provides platform-specific configurations
|
|
|
|
const PlatformDetector = {
|
|
// Detect current platform
|
|
getCurrentPlatform() {
|
|
const hostname = window.location.hostname;
|
|
const pathname = window.location.pathname;
|
|
|
|
if (hostname.includes('mail.google.com')) {
|
|
return 'gmail';
|
|
} else if (hostname.includes('app.instantly.ai')) {
|
|
return 'instantly';
|
|
} else if (hostname.includes('app.pipl.ai')) {
|
|
return 'plusvibe';
|
|
}
|
|
|
|
return 'unknown';
|
|
},
|
|
|
|
// Get platform-specific configuration
|
|
getConfig() {
|
|
const platform = this.getCurrentPlatform();
|
|
|
|
const configs = {
|
|
gmail: {
|
|
name: 'Gmail',
|
|
selectors: {
|
|
replyBox: 'div[aria-label="Message Body"], div[contenteditable="true"], div.editable',
|
|
threadContainer: 'div[role="listitem"]',
|
|
emailSender: 'span[email]',
|
|
emailSubject: 'h2[data-legacy-thread-id]',
|
|
composeButton: 'div[gh="cm"]',
|
|
checkboxes: 'div[role="checkbox"][aria-checked="true"]'
|
|
},
|
|
extractors: {
|
|
threadId: () => window.extractThreadId ? window.extractThreadId('current') : null,
|
|
selectedThreads: () => window.getSelectedThreadIds ? window.getSelectedThreadIds() : []
|
|
}
|
|
},
|
|
instantly: {
|
|
name: 'Instantly',
|
|
selectors: {
|
|
replyBox: 'div[contenteditable="true"], textarea.reply-input, div.message-composer',
|
|
threadContainer: '.conversation-message, .message-item',
|
|
emailSender: '.sender-name, .from-email',
|
|
emailSubject: '.subject-line, .conversation-subject',
|
|
composeButton: '.reply-button, .compose-button',
|
|
conversationList: '.conversation-item, .thread-item'
|
|
},
|
|
extractors: {
|
|
threadId: () => InstantlyExtractor.getCurrentThreadId(),
|
|
selectedThreads: () => InstantlyExtractor.getSelectedThreads()
|
|
}
|
|
},
|
|
plusvibe: {
|
|
name: 'Plusvibe',
|
|
selectors: {
|
|
replyBox: 'div[contenteditable="true"], textarea.reply-input, .compose-input, .message-input',
|
|
threadContainer: '.thread-container, .message-container, .conversation',
|
|
emailSender: '.sender, .from, .email-from',
|
|
emailSubject: '.subject, .email-subject',
|
|
composeButton: '.reply-btn, .compose-btn, button[aria-label*="reply"]',
|
|
conversationList: '.inbox-item, .thread-item, .conversation-item'
|
|
},
|
|
extractors: {
|
|
threadId: () => PlusvibeExtractor.getCurrentThreadId(),
|
|
selectedThreads: () => PlusvibeExtractor.getSelectedThreads()
|
|
}
|
|
}
|
|
};
|
|
|
|
return configs[platform] || null;
|
|
},
|
|
|
|
// Check if we should activate on current page
|
|
shouldActivate() {
|
|
const platform = this.getCurrentPlatform();
|
|
|
|
if (platform === 'gmail') {
|
|
return true; // Always active on Gmail
|
|
} else if (platform === 'instantly') {
|
|
// Only activate on Unibox pages
|
|
return window.location.pathname.includes('/unibox') ||
|
|
window.location.pathname.includes('/app/unibox');
|
|
} else if (platform === 'plusvibe') {
|
|
// Activate on Pipl.ai unibox/inbox pages
|
|
return window.location.pathname.includes('/unibox') ||
|
|
window.location.pathname.includes('/inbox');
|
|
}
|
|
|
|
return false;
|
|
}
|
|
};
|
|
|
|
// Export for use
|
|
if (typeof module !== 'undefined' && module.exports) {
|
|
module.exports = PlatformDetector;
|
|
}
|