@onairosofficial/onairos-capacitor 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/OnairosofficialOnairosCapacitor.podspec +1 -1
  2. package/README.md +1 -1
  3. package/dist/onairos.capacitor.esm.js +509 -1
  4. package/dist/onairos.capacitor.esm.turbopack.js +509 -1
  5. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +187 -945
  6. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosRNScrapers.swift +1800 -0
  7. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +180 -629
  8. package/onairos.d.ts +24 -0
  9. package/package.json +5 -2
  10. package/src/assets/connectors/Linkedinicon.png +0 -0
  11. package/src/assets/connectors/Redditicon.png +0 -0
  12. package/src/assets/connectors/YouTubeicon2.png +0 -0
  13. package/src/assets/connectors/chatgpt.png +0 -0
  14. package/src/assets/connectors/claude.png +0 -0
  15. package/src/assets/connectors/instagram.png +0 -0
  16. package/src/assets/connectors/netflix.png +0 -0
  17. package/src/assets/connectors/pinterest.png +0 -0
  18. package/src/assets/connectors/sephora.png +0 -0
  19. package/src/assets/connectors/spotify.png +0 -0
  20. package/src/assets/connectors/tiktok.png +0 -0
  21. package/src/assets/permissions/onairos.png +0 -0
  22. package/src/assets/permissions/personalization.png +0 -0
  23. package/src/assets/permissions/public-profile-person.png +0 -0
  24. package/src/assets/permissions/raw-memories.png +0 -0
  25. package/src/capacitorConnectorCatalog.js +2 -6
  26. package/src/components/DataRequest.jsx +96 -532
  27. package/src/components/EmailAuth.jsx +4 -116
  28. package/src/components/PinSetup.jsx +39 -226
  29. package/src/components/SDKDesignPreview.jsx +33 -0
  30. package/src/components/SessionUserBar.jsx +2 -1
  31. package/src/components/TrainingScreen.jsx +18 -12
  32. package/src/components/UniversalOnboarding.jsx +191 -424
  33. package/src/components/WelcomeScreen.jsx +19 -12
  34. package/src/components/parity/NativeConnections.jsx +136 -0
  35. package/src/components/parity/NativeScreens.jsx +48 -0
  36. package/src/components/ui/PageLayout.jsx +7 -3
  37. package/src/nativeImport/ConnectorLoading.jsx +13 -0
  38. package/src/nativeImport/CustomImportSession.js +115 -0
  39. package/src/nativeImport/ImportIcon.jsx +29 -0
  40. package/src/nativeImport/ImportProgress.jsx +24 -0
  41. package/src/nativeImport/ImportStatus.jsx +9 -0
  42. package/src/nativeImport/NativeChatImport.jsx +28 -0
  43. package/src/nativeImport/NativeImportSession.js +123 -0
  44. package/src/nativeImport/NativeScraperImport.jsx +57 -0
  45. package/src/nativeImport/SmartFilter.jsx +28 -0
  46. package/src/nativeImport/customPayload.js +37 -0
  47. package/src/nativeImport/netflixExport.js +30 -0
  48. package/src/nativeImport/netflixHistory.js +28 -0
  49. package/src/nativeImport/netflixSession.js +59 -0
  50. package/src/nativeImport/rawHandoff.js +7 -0
  51. package/src/nativeImport/rn/config/api.js +5 -0
  52. package/src/nativeImport/rn/services/apiKeyService.js +2 -0
  53. package/src/nativeImport/rn/services/hingePayload.js +37 -0
  54. package/src/nativeImport/rn/services/nativeConversationImport.js +138 -0
  55. package/src/nativeImport/rn/services/nativeFileTransfer.js +127 -0
  56. package/src/nativeImport/rn/services/nativeRawRedaction.js +136 -0
  57. package/src/nativeImport/rn/services/netflixPayload.js +70 -0
  58. package/src/nativeImport/rn/services/rawMemoryPolicy.js +38 -0
  59. package/src/nativeImport/rn/services/sephoraPayload.js +166 -0
  60. package/src/nativeImport/rn/services/spotifyPayload.js +99 -0
  61. package/src/nativeImport/rn/source-manifest.json +45 -0
  62. package/src/nativeImport/rn/utils/importedFiles.js +74 -0
  63. package/src/nativeImport/rn/utils/nativeImportDates.js +45 -0
  64. package/src/nativeImport/rn/utils/nativeImportFileReceiver.js +51 -0
  65. package/src/nativeImport/rn/utils/nativeImportMetadata.js +74 -0
  66. package/src/nativeImport/rn/utils/nativeImportTopics.js +56 -0
  67. package/src/nativeImport/rn/utils/rawExportDelivery.js +12 -0
  68. package/src/nativeImport/rn/utils/webviewScripts/chatgptDiscovery.js +99 -0
  69. package/src/nativeImport/rn/utils/webviewScripts/claude.js +349 -0
  70. package/src/nativeImport/rn/utils/webviewScripts/gemini.js +356 -0
  71. package/src/nativeImport/rn/utils/webviewScripts/hinge.js +375 -0
  72. package/src/nativeImport/rn/utils/webviewScripts/instagram.js +152 -0
  73. package/src/nativeImport/rn/utils/webviewScripts/linkedin.js +825 -0
  74. package/src/nativeImport/rn/utils/webviewScripts/nativeChatGPTImport.js +202 -0
  75. package/src/nativeImport/rn/utils/webviewScripts/nativeChatGPTSession.js +63 -0
  76. package/src/nativeImport/rn/utils/webviewScripts/nativeImportFiles.js +132 -0
  77. package/src/nativeImport/rn/utils/webviewScripts/nativeImportProviders.js +80 -0
  78. package/src/nativeImport/rn/utils/webviewScripts/nativeLoginViewport.js +28 -0
  79. package/src/nativeImport/rn/utils/webviewScripts/netflix.js +257 -0
  80. package/src/nativeImport/rn/utils/webviewScripts/sephora.js +862 -0
  81. package/src/nativeImport/rn/utils/webviewScripts/sephoraSession.js +160 -0
  82. package/src/nativeImport/rn/utils/webviewScripts/spotify.js +1868 -0
  83. package/src/nativeImport/rn/utils/webviewScripts/telegram.js +630 -0
  84. package/src/nativeImport/rn/utils/webviewScripts/tiktok.js +2920 -0
  85. package/src/onairos.capacitor.jsx +14 -2
  86. package/src/onairos.core.jsx +3 -0
  87. package/src/onairosButton.jsx +23 -17
  88. package/src/styles/onairos-fonts.css +20 -0
  89. package/src/styles/onairos-native.css +709 -0
  90. package/src/styles/onairos-rn-parity.css +175 -0
  91. package/src/styles/sdkCssRegistry.js +83 -1
  92. package/src/styles/tailwind.capacitor.css +6 -0
  93. package/src/utils/capacitorPlugins.js +20 -12
  94. package/src/utils/nativeConnectorSession.js +18 -0
  95. package/src/utils/parityPolicy.js +41 -0
@@ -0,0 +1,825 @@
1
+ // Synced from RN utils/webviewScripts/linkedin.ts by scripts/sync-rn-connectors.cjs.
2
+ const LINKEDIN_APP_BLOCKER_SCRIPT = `
3
+ (function() {
4
+ try {
5
+ // CRITICAL: Block ALL LinkedIn app deep link schemes
6
+ var blockedSchemes = ['linkedin://', 'linkedinapp://', 'linkedinssl://', 'linkedin-mobile://'];
7
+
8
+ function isBlockedUrl(url) {
9
+ if (!url || typeof url !== 'string') return false;
10
+ var urlLower = url.toLowerCase();
11
+ return blockedSchemes.some(function(scheme) {
12
+ return urlLower.startsWith(scheme);
13
+ }) || (urlLower.startsWith('intent://') && urlLower.includes('linkedin'));
14
+ }
15
+
16
+ // Block app deep links by intercepting link clicks (capture phase - earliest possible)
17
+ document.addEventListener('click', function(e) {
18
+ var target = e.target;
19
+ // Traverse up DOM to find anchor tag
20
+ while (target && target.tagName !== 'A' && target.tagName !== 'BUTTON') {
21
+ target = target.parentElement;
22
+ }
23
+
24
+ if (target) {
25
+ var href = target.href || target.getAttribute('href') || target.getAttribute('data-href');
26
+ if (href && isBlockedUrl(href)) {
27
+ e.preventDefault();
28
+ e.stopPropagation();
29
+ e.stopImmediatePropagation();
30
+ console.log('\u{1F6AB} [LINKEDIN-JS] Blocked app deep link click:', href);
31
+ return false;
32
+ }
33
+ }
34
+ }, true); // Capture phase - intercept before any other handlers
35
+
36
+ // Override window.open to prevent app opening
37
+ var originalOpen = window.open;
38
+ window.open = function(url, target, features) {
39
+ if (isBlockedUrl(url)) {
40
+ console.log('\u{1F6AB} [LINKEDIN-JS] Blocked window.open app link:', url);
41
+ return null;
42
+ }
43
+ return originalOpen.apply(this, arguments);
44
+ };
45
+
46
+ // Block location.href changes to app URLs
47
+ var originalLocation = window.location;
48
+ try {
49
+ Object.defineProperty(window, 'location', {
50
+ set: function(url) {
51
+ if (isBlockedUrl(url)) {
52
+ console.log('\u{1F6AB} [LINKEDIN-JS] Blocked location.href change to app URL:', url);
53
+ return;
54
+ }
55
+ originalLocation.href = url;
56
+ },
57
+ get: function() {
58
+ return originalLocation;
59
+ },
60
+ configurable: true
61
+ });
62
+ } catch (e) {
63
+ // Fallback: Override location.href directly
64
+ var originalHref = Object.getOwnPropertyDescriptor(window.location, 'href');
65
+ if (originalHref && originalHref.set) {
66
+ Object.defineProperty(window.location, 'href', {
67
+ set: function(url) {
68
+ if (isBlockedUrl(url)) {
69
+ console.log('\u{1F6AB} [LINKEDIN-JS] Blocked location.href setter to app URL:', url);
70
+ return;
71
+ }
72
+ originalHref.set.call(window.location, url);
73
+ },
74
+ get: originalHref.get,
75
+ configurable: true
76
+ });
77
+ }
78
+ }
79
+
80
+ // Block location.replace and location.assign
81
+ var originalReplace = window.location.replace;
82
+ window.location.replace = function(url) {
83
+ if (isBlockedUrl(url)) {
84
+ console.log('\u{1F6AB} [LINKEDIN-JS] Blocked location.replace to app URL:', url);
85
+ return;
86
+ }
87
+ return originalReplace.call(window.location, url);
88
+ };
89
+
90
+ var originalAssign = window.location.assign;
91
+ window.location.assign = function(url) {
92
+ if (isBlockedUrl(url)) {
93
+ console.log('\u{1F6AB} [LINKEDIN-JS] Blocked location.assign to app URL:', url);
94
+ return;
95
+ }
96
+ return originalAssign.call(window.location, url);
97
+ };
98
+
99
+ // Intercept meta refresh tags
100
+ var observer = new MutationObserver(function(mutations) {
101
+ mutations.forEach(function(mutation) {
102
+ mutation.addedNodes.forEach(function(node) {
103
+ if (node.nodeType === 1) { // Element node
104
+ if (node.tagName === 'META' && node.httpEquiv && node.httpEquiv.toLowerCase() === 'refresh') {
105
+ var content = node.content || node.getAttribute('content');
106
+ if (content && isBlockedUrl(content)) {
107
+ node.remove();
108
+ console.log('\u{1F6AB} [LINKEDIN-JS] Removed meta refresh to app URL');
109
+ }
110
+ }
111
+ // Check all links in added nodes
112
+ var links = node.querySelectorAll ? node.querySelectorAll('a[href]') : [];
113
+ links.forEach(function(link) {
114
+ if (isBlockedUrl(link.href)) {
115
+ link.href = '#';
116
+ link.onclick = function(e) {
117
+ e.preventDefault();
118
+ e.stopPropagation();
119
+ return false;
120
+ };
121
+ console.log('\u{1F6AB} [LINKEDIN-JS] Neutralized app deep link in added node');
122
+ }
123
+ });
124
+ }
125
+ });
126
+ });
127
+ });
128
+
129
+ // Start observing when DOM is ready
130
+ if (document.body) {
131
+ observer.observe(document.body, { childList: true, subtree: true });
132
+ } else {
133
+ document.addEventListener('DOMContentLoaded', function() {
134
+ observer.observe(document.body, { childList: true, subtree: true });
135
+ });
136
+ }
137
+
138
+ console.log('\u2705 [LINKEDIN-JS] App deep link blocker installed (comprehensive)');
139
+ } catch (e) {
140
+ console.error('\u274C [LINKEDIN-JS] App blocker error:', e);
141
+ }
142
+ })();
143
+ true;
144
+ `;
145
+ const LINKEDIN_PROFILE_EXTRACTOR_SCRIPT = `
146
+ (function() {
147
+ try {
148
+ if (!document.body) {
149
+ window.ReactNativeWebView.postMessage(JSON.stringify({
150
+ status: 'error',
151
+ message: 'Page not ready'
152
+ }));
153
+ return;
154
+ }
155
+
156
+ // ========================================
157
+ // 5 EXTRACTION METHODS (from iOS)
158
+ // ========================================
159
+
160
+ /**
161
+ * Method 1: Check current URL for /in/ pattern
162
+ */
163
+ function extractFromCurrentUrl() {
164
+ var currentUrl = window.location.href;
165
+ var inMatch = currentUrl.match(/linkedin\\.com\\/in\\/([^\\/\\?]+)/);
166
+
167
+ if (inMatch) {
168
+ return 'https://www.linkedin.com/in/' + inMatch[1];
169
+ }
170
+
171
+ return null;
172
+ }
173
+
174
+ /**
175
+ * Method 2: Search all links for /in/ pattern
176
+ */
177
+ function extractFromLinks() {
178
+ var allLinks = document.querySelectorAll('a[href*="/in/"]');
179
+
180
+ for (var i = 0; i < allLinks.length; i++) {
181
+ var href = allLinks[i].getAttribute('href') || allLinks[i].href;
182
+
183
+ if (href && href.includes('/in/') && !href.includes('/me')) {
184
+ var match = href.match(/https?:\\/\\/[^\\/]+\\/in\\/([^\\/\\?]+)/);
185
+ if (match) {
186
+ return 'https://www.linkedin.com/in/' + match[1];
187
+ }
188
+ }
189
+ }
190
+
191
+ return null;
192
+ }
193
+
194
+ /**
195
+ * Method 3: Check meta tags
196
+ */
197
+ function extractFromMetaTags() {
198
+ var metaTags = document.querySelectorAll('meta');
199
+
200
+ for (var i = 0; i < metaTags.length; i++) {
201
+ var content = metaTags[i].getAttribute('content') ||
202
+ metaTags[i].getAttribute('property') || '';
203
+
204
+ if (content && content.includes('/in/')) {
205
+ var match = content.match(/https?:\\/\\/[^\\/]+\\/in\\/([^\\/\\?]+)/);
206
+ if (match) {
207
+ return 'https://www.linkedin.com/in/' + match[1];
208
+ }
209
+ }
210
+ }
211
+
212
+ return null;
213
+ }
214
+
215
+ /**
216
+ * Method 4: Check scripts for embedded URLs
217
+ */
218
+ function extractFromScripts() {
219
+ var scripts = document.querySelectorAll('script');
220
+
221
+ for (var i = 0; i < scripts.length; i++) {
222
+ var scriptText = scripts[i].textContent || '';
223
+ var match = scriptText.match(/https?:\\/\\/[^\\/]+\\/in\\/([^\\/\\?"']+)/);
224
+
225
+ if (match && !match[0].includes('/me')) {
226
+ return 'https://www.linkedin.com/in/' + match[1];
227
+ }
228
+ }
229
+
230
+ return null;
231
+ }
232
+
233
+ /**
234
+ * Method 5: Check data attributes
235
+ */
236
+ function extractFromDataAttributes() {
237
+ var dataElems = document.querySelectorAll('[data-profile-url], [data-entity-urn]');
238
+
239
+ for (var i = 0; i < dataElems.length; i++) {
240
+ var dataUrl = dataElems[i].getAttribute('data-profile-url') ||
241
+ dataElems[i].getAttribute('href') || '';
242
+
243
+ if (dataUrl && dataUrl.includes('/in/')) {
244
+ var match = dataUrl.match(/https?:\\/\\/[^\\/]+\\/in\\/([^\\/\\?]+)/);
245
+ if (match) {
246
+ return 'https://www.linkedin.com/in/' + match[1];
247
+ }
248
+ }
249
+ }
250
+
251
+ return null;
252
+ }
253
+
254
+ // ========================================
255
+ // EXECUTE EXTRACTION
256
+ // ========================================
257
+
258
+ console.log('\u{1F50D} Starting LinkedIn profile URL extraction...');
259
+
260
+ // Try all 5 methods in order
261
+ var profileUrl = extractFromCurrentUrl() ||
262
+ extractFromLinks() ||
263
+ extractFromMetaTags() ||
264
+ extractFromScripts() ||
265
+ extractFromDataAttributes();
266
+
267
+ if (profileUrl) {
268
+ console.log('\u2705 Profile URL extracted:', profileUrl);
269
+
270
+ // Send success to React Native
271
+ window.ReactNativeWebView.postMessage(JSON.stringify({
272
+ status: 'success',
273
+ profileUrl: profileUrl
274
+ }));
275
+ } else {
276
+ console.warn('\u26A0\uFE0F Could not find LinkedIn profile URL');
277
+
278
+ // Send error to React Native
279
+ window.ReactNativeWebView.postMessage(JSON.stringify({
280
+ status: 'error',
281
+ message: 'Could not find LinkedIn profile URL. Please navigate to your profile page.'
282
+ }));
283
+ }
284
+
285
+ } catch (error) {
286
+ console.error('\u274C Error extracting profile URL:', error);
287
+
288
+ // Send error to React Native
289
+ window.ReactNativeWebView.postMessage(JSON.stringify({
290
+ status: 'error',
291
+ message: 'JavaScript error: ' + (error.message || String(error))
292
+ }));
293
+ }
294
+ })();
295
+ true; // Required for iOS compatibility
296
+ `;
297
+ const LINKEDIN_NAVIGATE_TO_PROFILE_SCRIPT = `
298
+ (function() {
299
+ try {
300
+ // Try clicking the "Me" menu item or profile link
301
+ var meLink = document.querySelector('a[href*="/me"]') ||
302
+ document.querySelector('a[href*="/in/"][href*="profile"]') ||
303
+ document.querySelector('[data-control-name="identity_welcome_message"]') ||
304
+ document.querySelector('a[aria-label*="Profile"]') ||
305
+ document.querySelector('a[aria-label*="Me"]');
306
+ if (meLink) {
307
+ console.log('[LINKEDIN] Found profile link, clicking...');
308
+ meLink.click();
309
+ return true;
310
+ }
311
+ // Fallback: navigate directly
312
+ console.log('[LINKEDIN] No profile link found, navigating directly to /me');
313
+ window.location.href = 'https://www.linkedin.com/me';
314
+ return false;
315
+ } catch (e) {
316
+ console.error('[LINKEDIN] Navigation error:', e);
317
+ window.location.href = 'https://www.linkedin.com/me';
318
+ return false;
319
+ }
320
+ })();
321
+ true;
322
+ `;
323
+ const LINKEDIN_PROFILE_CONSENT_POPUP_SCRIPT = `
324
+ (function() {
325
+ try {
326
+ const existing = document.getElementById('onairos-linkedin-consent-overlay');
327
+ if (existing) existing.remove();
328
+
329
+ const overlay = document.createElement('div');
330
+ overlay.id = 'onairos-linkedin-consent-overlay';
331
+ overlay.style.cssText = \`
332
+ position: fixed;
333
+ top: 0;
334
+ left: 0;
335
+ width: 100%;
336
+ height: 100%;
337
+ background: rgba(0, 0, 0, 0.7);
338
+ z-index: 999999;
339
+ display: flex;
340
+ align-items: center;
341
+ justify-content: center;
342
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
343
+ \`;
344
+
345
+ const popup = document.createElement('div');
346
+ popup.style.cssText = \`
347
+ background: white;
348
+ border-radius: 16px;
349
+ padding: 32px;
350
+ max-width: 400px;
351
+ width: 90%;
352
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
353
+ \`;
354
+
355
+ popup.innerHTML = \`
356
+ <div style="text-align: center;">
357
+ <div style="font-size: 48px; margin-bottom: 16px;">\u{1F4BC}</div>
358
+ <h2 style="margin: 0 0 12px 0; font-size: 24px; color: #1a1a1a;">
359
+ Import LinkedIn Profile?
360
+ </h2>
361
+ <p style="margin: 0 0 24px 0; color: #666; font-size: 16px; line-height: 1.5;">
362
+ Allow Onairos to import your LinkedIn profile data including bio, work history, education, and skills?
363
+ </p>
364
+ <div style="display: flex; gap: 12px; justify-content: center;">
365
+ <button id="onairos-linkedin-deny" style="
366
+ flex: 1;
367
+ padding: 14px 24px;
368
+ border: 2px solid #e0e0e0;
369
+ background: white;
370
+ color: #666;
371
+ border-radius: 8px;
372
+ font-size: 16px;
373
+ font-weight: 600;
374
+ cursor: pointer;
375
+ ">Deny</button>
376
+ <button id="onairos-linkedin-allow" style="
377
+ flex: 1;
378
+ padding: 14px 24px;
379
+ border: none;
380
+ background: #0077B5;
381
+ color: white;
382
+ border-radius: 8px;
383
+ font-size: 16px;
384
+ font-weight: 600;
385
+ cursor: pointer;
386
+ ">Allow</button>
387
+ </div>
388
+ </div>
389
+ \`;
390
+
391
+ overlay.appendChild(popup);
392
+ document.body.appendChild(overlay);
393
+
394
+ document.getElementById('onairos-linkedin-deny').onclick = () => {
395
+ overlay.remove();
396
+ window.ReactNativeWebView.postMessage(JSON.stringify({
397
+ type: 'LINKEDIN_PROFILE_CONSENT',
398
+ status: 'denied'
399
+ }));
400
+ };
401
+
402
+ document.getElementById('onairos-linkedin-allow').onclick = () => {
403
+ document.getElementById('onairos-linkedin-allow').innerHTML = '\u23F3 Extracting...';
404
+ document.getElementById('onairos-linkedin-allow').disabled = true;
405
+
406
+ window.ReactNativeWebView.postMessage(JSON.stringify({
407
+ type: 'LINKEDIN_PROFILE_CONSENT',
408
+ status: 'allowed'
409
+ }));
410
+
411
+ setTimeout(() => overlay.remove(), 500);
412
+ };
413
+ } catch (error) {
414
+ window.ReactNativeWebView.postMessage(JSON.stringify({
415
+ type: 'LINKEDIN_PROFILE_CONSENT',
416
+ status: 'error',
417
+ message: error.message
418
+ }));
419
+ }
420
+ })();
421
+ true;
422
+ `;
423
+ const LINKEDIN_PROFILE_SCRAPER_SCRIPT = `
424
+ (function() {
425
+ try {
426
+ console.log('\u{1F50D} [LINKEDIN] Starting profile DOM extraction...');
427
+
428
+ window.ReactNativeWebView.postMessage(JSON.stringify({
429
+ type: 'LINKEDIN_PROFILE_PROGRESS',
430
+ stage: 'starting',
431
+ progress: 5,
432
+ message: 'Starting profile extraction...'
433
+ }));
434
+
435
+ // ========================================
436
+ // HELPER FUNCTIONS
437
+ // ========================================
438
+
439
+ function getTextContent(selector, parent = document) {
440
+ const el = parent.querySelector(selector);
441
+ return el ? el.textContent.trim() : '';
442
+ }
443
+
444
+ function getAllTextContent(selector, parent = document) {
445
+ const elements = parent.querySelectorAll(selector);
446
+ return Array.from(elements).map(el => el.textContent.trim()).filter(t => t);
447
+ }
448
+
449
+ function cleanText(text) {
450
+ if (!text) return '';
451
+ return text.replace(/\\s+/g, ' ').trim();
452
+ }
453
+
454
+ // ========================================
455
+ // EXTRACT BASIC INFO
456
+ // ========================================
457
+
458
+ window.ReactNativeWebView.postMessage(JSON.stringify({
459
+ type: 'LINKEDIN_PROFILE_PROGRESS',
460
+ stage: 'basic_info',
461
+ progress: 10,
462
+ message: 'Extracting basic info...'
463
+ }));
464
+
465
+ // Name - try multiple selectors
466
+ let fullName = '';
467
+ const nameSelectors = [
468
+ 'h1',
469
+ '.text-heading-xlarge',
470
+ '[data-anonymize="person-name"]',
471
+ '.pv-text-details__left-panel h1',
472
+ '.profile-topcard-person-entity__name'
473
+ ];
474
+ for (const sel of nameSelectors) {
475
+ const name = getTextContent(sel);
476
+ if (name && name.length > 1 && name.length < 100) {
477
+ fullName = cleanText(name);
478
+ break;
479
+ }
480
+ }
481
+ console.log('\u{1F4DB} [LINKEDIN] Name:', fullName);
482
+
483
+ // Headline - try multiple selectors
484
+ let headline = '';
485
+ const headlineSelectors = [
486
+ '.text-body-medium.break-words',
487
+ '[data-anonymize="headline"]',
488
+ '.pv-text-details__left-panel .text-body-medium',
489
+ '.profile-topcard__summary-position-title'
490
+ ];
491
+ for (const sel of headlineSelectors) {
492
+ const h = getTextContent(sel);
493
+ if (h && h.length > 3) {
494
+ headline = cleanText(h);
495
+ break;
496
+ }
497
+ }
498
+ console.log('\u{1F4CB} [LINKEDIN] Headline:', headline);
499
+
500
+ // Location
501
+ let location = '';
502
+ const locationSelectors = [
503
+ '.text-body-small.inline.t-black--light.break-words',
504
+ '.pv-text-details__left-panel .text-body-small',
505
+ '[data-anonymize="location"]',
506
+ '.profile-topcard__location-data'
507
+ ];
508
+ for (const sel of locationSelectors) {
509
+ const loc = getTextContent(sel);
510
+ if (loc && loc.length > 2 && !loc.includes('connections') && !loc.includes('followers')) {
511
+ location = cleanText(loc);
512
+ break;
513
+ }
514
+ }
515
+ console.log('\u{1F4CD} [LINKEDIN] Location:', location);
516
+
517
+ // Profile URL
518
+ const profileUrl = window.location.href.split('?')[0];
519
+ console.log('\u{1F517} [LINKEDIN] Profile URL:', profileUrl);
520
+
521
+ // ========================================
522
+ // EXTRACT ABOUT SECTION
523
+ // ========================================
524
+
525
+ window.ReactNativeWebView.postMessage(JSON.stringify({
526
+ type: 'LINKEDIN_PROFILE_PROGRESS',
527
+ stage: 'about',
528
+ progress: 25,
529
+ message: 'Extracting about section...'
530
+ }));
531
+
532
+ let about = '';
533
+
534
+ // Try to find About section
535
+ const aboutSection = document.querySelector('#about') ||
536
+ document.querySelector('[id*="about"]') ||
537
+ document.querySelector('section:has(> div > div > span:contains("About"))');
538
+
539
+ if (aboutSection) {
540
+ // Look for the about text within the section
541
+ const aboutTextSelectors = [
542
+ '.display-flex.ph5.pv3 span[aria-hidden="true"]',
543
+ '.pv-shared-text-with-see-more span',
544
+ '.inline-show-more-text span',
545
+ 'span[aria-hidden="true"]',
546
+ '.full-width span'
547
+ ];
548
+
549
+ for (const sel of aboutTextSelectors) {
550
+ const texts = aboutSection.querySelectorAll(sel);
551
+ if (texts.length > 0) {
552
+ about = cleanText(Array.from(texts).map(t => t.textContent).join(' '));
553
+ if (about.length > 20) break;
554
+ }
555
+ }
556
+ }
557
+
558
+ // Alternative: look for about text near "About" heading
559
+ if (!about) {
560
+ const allSpans = document.querySelectorAll('span');
561
+ let foundAboutHeading = false;
562
+ for (const span of allSpans) {
563
+ if (span.textContent.trim() === 'About') {
564
+ foundAboutHeading = true;
565
+ continue;
566
+ }
567
+ if (foundAboutHeading && span.textContent.length > 50) {
568
+ about = cleanText(span.textContent);
569
+ break;
570
+ }
571
+ }
572
+ }
573
+ console.log('\u{1F4DD} [LINKEDIN] About present:', !!about);
574
+
575
+ // ========================================
576
+ // EXTRACT EXPERIENCE
577
+ // ========================================
578
+
579
+ window.ReactNativeWebView.postMessage(JSON.stringify({
580
+ type: 'LINKEDIN_PROFILE_PROGRESS',
581
+ stage: 'experience',
582
+ progress: 40,
583
+ message: 'Extracting work experience...'
584
+ }));
585
+
586
+ const experience = [];
587
+
588
+ // Find experience section
589
+ const expSection = document.querySelector('#experience') ||
590
+ document.querySelector('[id*="experience"]') ||
591
+ document.querySelector('section.experience-section');
592
+
593
+ if (expSection) {
594
+ // Look for experience entries - LinkedIn uses list items
595
+ const expItems = expSection.querySelectorAll('li.artdeco-list__item, li[class*="experience-item"], ul > li');
596
+
597
+ for (const item of expItems) {
598
+ const entry = {};
599
+
600
+ // Title - usually the first/main heading in the item
601
+ const titleEl = item.querySelector('.t-bold span, .mr1.t-bold span, [data-anonymize="job-title"]');
602
+ if (titleEl) entry.title = cleanText(titleEl.textContent);
603
+
604
+ // Company
605
+ const companyEl = item.querySelector('.t-normal span, .t-14.t-normal span, [data-anonymize="company-name"]');
606
+ if (companyEl) entry.company = cleanText(companyEl.textContent);
607
+
608
+ // Duration/dates
609
+ const dateEl = item.querySelector('.t-black--light span, .pvs-entity__caption-wrapper');
610
+ if (dateEl) entry.duration = cleanText(dateEl.textContent);
611
+
612
+ // Description
613
+ const descEl = item.querySelector('.display-flex.align-items-center span[aria-hidden="true"], .inline-show-more-text');
614
+ if (descEl) entry.description = cleanText(descEl.textContent);
615
+
616
+ // Location
617
+ const locEl = item.querySelector('.t-black--light.t-normal span:last-child');
618
+ if (locEl) entry.location = cleanText(locEl.textContent);
619
+
620
+ if (entry.title || entry.company) {
621
+ experience.push(entry);
622
+ }
623
+ }
624
+ }
625
+ console.log('\u{1F4BC} [LINKEDIN] Experience entries:', experience.length);
626
+
627
+ // ========================================
628
+ // EXTRACT EDUCATION
629
+ // ========================================
630
+
631
+ window.ReactNativeWebView.postMessage(JSON.stringify({
632
+ type: 'LINKEDIN_PROFILE_PROGRESS',
633
+ stage: 'education',
634
+ progress: 60,
635
+ message: 'Extracting education...'
636
+ }));
637
+
638
+ const education = [];
639
+
640
+ // Find education section
641
+ const eduSection = document.querySelector('#education') ||
642
+ document.querySelector('[id*="education"]') ||
643
+ document.querySelector('section.education-section');
644
+
645
+ if (eduSection) {
646
+ const eduItems = eduSection.querySelectorAll('li.artdeco-list__item, li[class*="education-item"], ul > li');
647
+
648
+ for (const item of eduItems) {
649
+ const entry = {};
650
+
651
+ // School name
652
+ const schoolEl = item.querySelector('.t-bold span, .mr1.t-bold span, [data-anonymize="school-name"]');
653
+ if (schoolEl) entry.school = cleanText(schoolEl.textContent);
654
+
655
+ // Degree
656
+ const degreeEl = item.querySelector('.t-normal span, .t-14.t-normal span');
657
+ if (degreeEl) entry.degree = cleanText(degreeEl.textContent);
658
+
659
+ // Field of study (sometimes combined with degree)
660
+ const fieldEl = item.querySelector('.pv-entity__comma-item');
661
+ if (fieldEl) entry.fieldOfStudy = cleanText(fieldEl.textContent);
662
+
663
+ // Years
664
+ const yearsEl = item.querySelector('.t-black--light span, .pvs-entity__caption-wrapper');
665
+ if (yearsEl) entry.years = cleanText(yearsEl.textContent);
666
+
667
+ if (entry.school) {
668
+ education.push(entry);
669
+ }
670
+ }
671
+ }
672
+ console.log('\u{1F393} [LINKEDIN] Education entries:', education.length);
673
+
674
+ // ========================================
675
+ // EXTRACT SKILLS
676
+ // ========================================
677
+
678
+ window.ReactNativeWebView.postMessage(JSON.stringify({
679
+ type: 'LINKEDIN_PROFILE_PROGRESS',
680
+ stage: 'skills',
681
+ progress: 80,
682
+ message: 'Extracting skills...'
683
+ }));
684
+
685
+ const skills = [];
686
+
687
+ // Find skills section
688
+ const skillsSection = document.querySelector('#skills') ||
689
+ document.querySelector('[id*="skills"]') ||
690
+ document.querySelector('section.skills-section');
691
+
692
+ if (skillsSection) {
693
+ const skillItems = skillsSection.querySelectorAll('.t-bold span, [data-anonymize="skill-name"], .pv-skill-category-entity__name-text');
694
+
695
+ for (const item of skillItems) {
696
+ const skill = cleanText(item.textContent);
697
+ if (skill && skill.length > 1 && skill.length < 100 && !skills.includes(skill)) {
698
+ skills.push(skill);
699
+ }
700
+ }
701
+ }
702
+
703
+ // Also check for skills in "Top skills" section on profile card
704
+ const topSkillsSection = document.querySelector('.pv-skill-category-list');
705
+ if (topSkillsSection) {
706
+ const topSkillItems = topSkillsSection.querySelectorAll('span');
707
+ for (const item of topSkillItems) {
708
+ const skill = cleanText(item.textContent);
709
+ if (skill && skill.length > 1 && skill.length < 100 && !skills.includes(skill)) {
710
+ skills.push(skill);
711
+ }
712
+ }
713
+ }
714
+ console.log('\u{1F6E0}\uFE0F [LINKEDIN] Skills:', skills.length);
715
+
716
+ // ========================================
717
+ // EXTRACT ADDITIONAL INFO
718
+ // ========================================
719
+
720
+ // Connections count
721
+ let connections = 0;
722
+ const connectionsEl = document.querySelector('.t-bold:has(+ span:contains("connections")), .pv-top-card--list-bullet span');
723
+ if (connectionsEl) {
724
+ const connText = connectionsEl.textContent;
725
+ const connMatch = connText.match(/([\\d,]+)\\+?\\s*connections?/i);
726
+ if (connMatch) {
727
+ connections = parseInt(connMatch[1].replace(/,/g, ''));
728
+ }
729
+ }
730
+
731
+ // Profile picture URL
732
+ let profilePicture = '';
733
+ const imgEl = document.querySelector('.pv-top-card-profile-picture__image, .profile-photo-edit__preview, img[data-anonymize="headshot-photo"]');
734
+ if (imgEl && imgEl.src) {
735
+ profilePicture = imgEl.src;
736
+ }
737
+
738
+ // ========================================
739
+ // BUILD RESULT OBJECT
740
+ // ========================================
741
+
742
+ window.ReactNativeWebView.postMessage(JSON.stringify({
743
+ type: 'LINKEDIN_PROFILE_PROGRESS',
744
+ stage: 'finalizing',
745
+ progress: 95,
746
+ message: 'Finalizing extraction...'
747
+ }));
748
+
749
+ const profileData = {
750
+ // Basic Info
751
+ fullName: fullName,
752
+ headline: headline,
753
+ location: location,
754
+ about: about,
755
+ profileUrl: profileUrl,
756
+
757
+ // Profile Details
758
+ profilePicture: profilePicture,
759
+
760
+ // Professional Info
761
+ experience: experience,
762
+ education: education,
763
+ skills: skills,
764
+
765
+ // Additional Info
766
+ connections: connections,
767
+
768
+ // Metadata
769
+ scrapedAt: new Date().toISOString(),
770
+ extractionMethod: 'dom_scraper'
771
+ };
772
+
773
+ console.log('\u2705 [LINKEDIN] Profile extraction complete!');
774
+ console.log('\u{1F4CA} [LINKEDIN] Summary:', {
775
+ hasName: !!fullName,
776
+ hasHeadline: !!headline,
777
+ experienceCount: experience.length,
778
+ educationCount: education.length,
779
+ skillsCount: skills.length
780
+ });
781
+
782
+ // ========================================
783
+ // SEND RESULT TO REACT NATIVE
784
+ // ========================================
785
+
786
+ window.ReactNativeWebView.postMessage(JSON.stringify({
787
+ type: 'LINKEDIN_PROFILE_EXPORT_COMPLETE',
788
+ status: 'success',
789
+ data: profileData,
790
+ success: true
791
+ }));
792
+
793
+ } catch (error) {
794
+ console.error('\u274C [LINKEDIN] Profile extraction error:', error);
795
+ window.ReactNativeWebView.postMessage(JSON.stringify({
796
+ type: 'LINKEDIN_PROFILE_EXPORT_ERROR',
797
+ status: 'error',
798
+ message: 'Extraction failed: ' + error.message,
799
+ success: false
800
+ }));
801
+ }
802
+ })();
803
+ true;
804
+ `;
805
+ const LINKEDIN_PROFILE_SUCCESS_SCRIPT = `
806
+ (function() {
807
+ console.log('\u2705 LinkedIn profile export successful!');
808
+ })();
809
+ true;
810
+ `;
811
+ const LINKEDIN_PROFILE_ERROR_SCRIPT = `
812
+ (function() {
813
+ console.log('\u274C LinkedIn profile export failed!');
814
+ })();
815
+ true;
816
+ `;
817
+ export {
818
+ LINKEDIN_APP_BLOCKER_SCRIPT,
819
+ LINKEDIN_NAVIGATE_TO_PROFILE_SCRIPT,
820
+ LINKEDIN_PROFILE_CONSENT_POPUP_SCRIPT,
821
+ LINKEDIN_PROFILE_ERROR_SCRIPT,
822
+ LINKEDIN_PROFILE_EXTRACTOR_SCRIPT,
823
+ LINKEDIN_PROFILE_SCRAPER_SCRIPT,
824
+ LINKEDIN_PROFILE_SUCCESS_SCRIPT
825
+ };