@onairosofficial/onairos-capacitor 0.1.0 → 0.1.1
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.
- package/LICENSE +194 -10
- package/README.md +182 -25
- package/dist/onairos.capacitor.esm.js +1 -0
- package/dist/onairos.capacitor.esm.turbopack.js +1 -0
- package/onairos.d.ts +656 -0
- package/package.json +186 -38
- package/src/OnairosReconnectButton.jsx +272 -0
- package/src/RSA.jsx +57 -0
- package/src/assets/NewLogo.png +0 -0
- package/src/assets/OnairosNewLogo.png +0 -0
- package/src/assets/chatgpt-icon.png +0 -0
- package/src/assets/fire-horse.png +0 -0
- package/src/assets/fire-horse.transparent.png +0 -0
- package/src/assets/latest-firehorse.png +0 -0
- package/src/assets/perplexity.png +0 -0
- package/src/assets/persona.png +0 -0
- package/src/assets/persona1.png +0 -0
- package/src/assets/persona2.png +0 -0
- package/src/assets/persona3.png +0 -0
- package/src/assets/persona4.png +0 -0
- package/src/assets/persona5.png +0 -0
- package/src/capacitorConnectorCatalog.js +38 -0
- package/src/capacitorOAuthConfig.js +52 -0
- package/src/chatgptHostedImport/index.js +303 -0
- package/src/components/AuthButtons.jsx +48 -0
- package/src/components/ConnectChatGPTModal.jsx +666 -0
- package/src/components/ConnectClaudeModal.jsx +610 -0
- package/src/components/ConnectGeminiModal.jsx +639 -0
- package/src/components/ConnectGrokModal.jsx +701 -0
- package/src/components/ConnectPerplexityModal.jsx +726 -0
- package/src/components/DataExplainerScreen.jsx +349 -0
- package/src/components/DataRequest.js +885 -0
- package/src/components/DataRequest.jsx +1055 -0
- package/src/components/EmailAuth.js +1871 -0
- package/src/components/EmailAuth.jsx +2062 -0
- package/src/components/ExtensionInstallPrompt.jsx +142 -0
- package/src/components/GoogleButton.js +133 -0
- package/src/components/LLMConnectorManager.jsx +201 -0
- package/src/components/LoadingPage.jsx +19 -0
- package/src/components/LoadingScreen.jsx +81 -0
- package/src/components/LunarBirthdate.jsx +96 -0
- package/src/components/LunarLoadingPage.jsx +251 -0
- package/src/components/Notification.jsx +21 -0
- package/src/components/OnairosAppButton.jsx +85 -0
- package/src/components/OnairosSSO.jsx +645 -0
- package/src/components/OnairosTrigger.jsx +61 -0
- package/src/components/PerplexityLogo.jsx +43 -0
- package/src/components/PinSetup.js +200 -0
- package/src/components/PinSetup.jsx +228 -0
- package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
- package/src/components/SdkErrorBoundary.jsx +36 -0
- package/src/components/SecuritySetup.js +81 -0
- package/src/components/SessionUserBar.jsx +83 -0
- package/src/components/SignUp.js +123 -0
- package/src/components/TestTelegramButton.js +53 -0
- package/src/components/TrainingComponent.jsx +200 -0
- package/src/components/TrainingScreen.jsx +897 -0
- package/src/components/UniversalOnboarding.js +306 -0
- package/src/components/UniversalOnboarding.jsx +4837 -0
- package/src/components/ValentineLoadingPage.jsx +502 -0
- package/src/components/ValentineModeSelector.jsx +162 -0
- package/src/components/WelcomeScreen.jsx +435 -0
- package/src/components/WrappedLoadingPage.jsx +205 -0
- package/src/components/connectors/ChatGPTConnector.js +348 -0
- package/src/components/connectors/ChatGPTConnector.jsx +348 -0
- package/src/components/connectors/ClaudeConnector.js +44 -0
- package/src/components/connectors/ClaudeConnector.jsx +44 -0
- package/src/components/connectors/GeminiConnector.js +170 -0
- package/src/components/connectors/GeminiConnector.jsx +170 -0
- package/src/components/connectors/GmailConnector.js +148 -0
- package/src/components/connectors/GmailConnector.jsx +148 -0
- package/src/components/connectors/GrokConnector.js +16 -0
- package/src/components/connectors/GrokConnector.jsx +16 -0
- package/src/components/connectors/HingeConnector.js +419 -0
- package/src/components/connectors/HingeConnector.jsx +419 -0
- package/src/components/connectors/InstagramDataConnector.js +726 -0
- package/src/components/connectors/InstagramDataConnector.jsx +726 -0
- package/src/components/connectors/LinkedInConnector.js +4 -0
- package/src/components/connectors/LinkedInConnector.jsx +296 -0
- package/src/components/connectors/PerplexityConnector.jsx +16 -0
- package/src/components/connectors/PinterestConnector.js +208 -0
- package/src/components/connectors/PinterestConnector.jsx +208 -0
- package/src/components/connectors/README.md +292 -0
- package/src/components/connectors/RedditConnector.js +229 -0
- package/src/components/connectors/RedditConnector.jsx +229 -0
- package/src/components/connectors/SephoraConnector.js +482 -0
- package/src/components/connectors/SephoraConnector.jsx +482 -0
- package/src/components/connectors/TikTokConnector.jsx +430 -0
- package/src/components/connectors/YoutubeConnector.js +361 -0
- package/src/components/connectors/YoutubeConnector.jsx +361 -0
- package/src/components/connectors/index.js +50 -0
- package/src/components/icons.jsx +46 -0
- package/src/components/icons.tsx +21 -0
- package/src/components/ui/PageLayout.jsx +1255 -0
- package/src/components/ui/PrimaryButton.jsx +162 -0
- package/src/components/ui/button.jsx +49 -0
- package/src/components/ui/card.jsx +61 -0
- package/src/components/ui/checkbox.jsx +33 -0
- package/src/components/ui/label.jsx +29 -0
- package/src/components/utils/UpdateConnections.js +45 -0
- package/src/components/utils/oauthHelper.js +97 -0
- package/src/config/api-config.js +138 -0
- package/src/deepLink.jsx +38 -0
- package/src/getPin.js +26 -0
- package/src/icons/Avatar.png +0 -0
- package/src/icons/Sentiment.png +0 -0
- package/src/icons/Trait.png +0 -0
- package/src/iframe/DataRequestPage.jsx +285 -0
- package/src/iframe/OnairosButtonIntegration.md +148 -0
- package/src/iframe/components/Box.jsx +56 -0
- package/src/iframe/components/IndividualConnection.jsx +88 -0
- package/src/iframe/dataRequestHandler.js +714 -0
- package/src/iframe/data_request_iframe.html +27 -0
- package/src/iframe/data_request_page.js +47 -0
- package/src/iframe/icons/Avatar.png +1 -0
- package/src/iframe/icons/Avatar2.png +1 -0
- package/src/iframe/icons/Sentiment.png +1 -0
- package/src/iframe/icons/Trait.png +1 -0
- package/src/iframe/icons/onairos_logo.png +0 -0
- package/src/iframe/utils/api.js +57 -0
- package/src/index.js +274 -0
- package/src/laravel/OnairosVue.vue +410 -0
- package/src/laravel/blade-helpers.js +320 -0
- package/src/laravel/vite-plugin.js +179 -0
- package/src/mobile/MobileDataRequestPage.jsx +233 -0
- package/src/mobile/components/MobileBox.jsx +71 -0
- package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
- package/src/mobile/shims/browser-apis.js +78 -0
- package/src/mobile/shims/lucide-shim.js +85 -0
- package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
- package/src/newUI/PlatformConnectorsStep.tsx +435 -0
- package/src/newUI/PrimaryButton.tsx +213 -0
- package/src/newUI/SignInStep.tsx +194 -0
- package/src/newUI/VerificationStep.tsx +133 -0
- package/src/newUI/WelcomeScreen.tsx +311 -0
- package/src/newUI/services/connectedAccountsService.js +129 -0
- package/src/onairos.capacitor.jsx +16 -0
- package/src/onairos.core.jsx +133 -0
- package/src/onairos.jsx +14 -0
- package/src/onairos.native.jsx +15 -0
- package/src/onairosButton.jsx +9000 -0
- package/src/overlay/CheckBox.jsx +114 -0
- package/src/overlay/IndividualConnection copy.js +86 -0
- package/src/overlay/IndividualConnection.js +191 -0
- package/src/overlay/IndividualConnectionNew.jsx +157 -0
- package/src/overlay/box.js +84 -0
- package/src/overlay/overlay.js +437 -0
- package/src/styles/onairos-scoped-preflight.css +97 -0
- package/src/styles/sdkCssRegistry.js +20 -0
- package/src/styles/styleLoaderInsertShadow.js +69 -0
- package/src/styles/tailwind.capacitor.css +395 -0
- package/src/styles/tailwind.css +395 -0
- package/src/theme/colors.js +40 -0
- package/src/utils/apiKeyValidation.js +341 -0
- package/src/utils/apiResponseLogger.js +316 -0
- package/src/utils/authHeaders.js +275 -0
- package/src/utils/biometrics.js +26 -0
- package/src/utils/bookmarkletUtils.js +28 -0
- package/src/utils/capacitorDetection.js +278 -0
- package/src/utils/capacitorLLMHelper.js +352 -0
- package/src/utils/capacitorPlugins.js +366 -0
- package/src/utils/crossDomainSSO.js +587 -0
- package/src/utils/deepLinking.js +27 -0
- package/src/utils/devLogger.js +46 -0
- package/src/utils/extensionDetection.js +418 -0
- package/src/utils/extractMemory.js +277 -0
- package/src/utils/framerBrandingOverrides.js +40 -0
- package/src/utils/googleWebClientId.js +55 -0
- package/src/utils/overlayHandler.js +224 -0
- package/src/utils/platformDisconnect.js +309 -0
- package/src/utils/pollTrainingStatus.js +200 -0
- package/src/utils/rawMemoriesAccess.js +211 -0
- package/src/utils/resolveBackendAppId.js +47 -0
- package/src/utils/responseFormatter.js +140 -0
- package/src/utils/sdkDebugStorage.js +113 -0
- package/src/utils/sdkInitialization.js +645 -0
- package/src/utils/sessionManager.js +1258 -0
- package/src/utils/startBackgroundTraining.js +100 -0
- package/src/utils/userDataFormatter.js +222 -0
- package/index.d.ts +0 -1
- package/index.js +0 -1
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
import { getApiBaseUrl } from '../config/api-config.js';
|
|
4
|
+
import { getApiKey, getUserToken } from '../utils/authHeaders.js';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_IMPORT_BRIDGE_URL = 'https://onairos.io/extract-data/';
|
|
7
|
+
|
|
8
|
+
// Gemini bookmarklet: use the live batchexecute detail path first, then fall back to DOM extraction.
|
|
9
|
+
// Extraction stays on the provider page; the shared import bridge opens only after data is ready.
|
|
10
|
+
const GEMINI_BOOKMARKLET_HREF =
|
|
11
|
+
[
|
|
12
|
+
"javascript:(async function(){try{",
|
|
13
|
+
"var host=(location.hostname||'').toLowerCase();",
|
|
14
|
+
"if(!(host==='gemini.google.com'||host.endsWith('.gemini.google.com'))){alert('Please open Gemini first.');return;}",
|
|
15
|
+
"var BRIDGE='__BRIDGE_URL__';",
|
|
16
|
+
"var BRIDGE_ORIGIN='__BRIDGE_ORIGIN__';",
|
|
17
|
+
"var APP_ORIGIN='__ONAIROS_ORIGIN__';",
|
|
18
|
+
"var notifyApp=function(msg){try{if(window.opener){window.opener.postMessage(msg,APP_ORIGIN);}}catch(_){}};",
|
|
19
|
+
"var clean=function(t){return String(t||'').replace(/(?:^|\\n)https?:\\/\\/googleusercontent\\.com\\/[^\\n]+/g,'').replace(/\\n{3,}/g,'\\n\\n').trim();};",
|
|
20
|
+
"var hintEl=null;",
|
|
21
|
+
"var setHint=function(m){try{if(!hintEl){hintEl=document.createElement('div');hintEl.setAttribute('data-gemini-export-status','1');hintEl.style.cssText='position:fixed;top:16px;right:16px;z-index:2147483647;max-width:260px;padding:8px 12px;border-radius:999px;background:rgba(15,23,42,.88);color:#fff;font:12px/1.2 -apple-system,BlinkMacSystemFont,Segoe UI,system-ui,sans-serif;box-shadow:0 10px 30px rgba(0,0,0,.22);pointer-events:none;opacity:.96;letter-spacing:.01em';document.body.appendChild(hintEl);}hintEl.textContent=String(m||'Preparing export...');}catch(_){}};",
|
|
22
|
+
"var clearHint=function(){try{if(hintEl&&hintEl.parentNode)hintEl.parentNode.removeChild(hintEl);}catch(_){}hintEl=null;};",
|
|
23
|
+
"setHint('Getting your memories...');",
|
|
24
|
+
"var getPageTitle=function(){return ((document.title||'').replace(/ - Google.*/i,'').replace(/^Google\\s+Gemini$/i,'').replace(/^Gemini$/i,'').trim())||'Gemini Conversation';};",
|
|
25
|
+
"var wait=function(ms){return new Promise(function(resolve){setTimeout(resolve,ms||0)});};",
|
|
26
|
+
"var parseConversationId=function(v){var m=String(v||'').match(/\\/app\\/([a-zA-Z0-9_-]{6,128})/);return m&&m[1]?m[1]:null;};",
|
|
27
|
+
"var curId=parseConversationId(location.pathname)||parseConversationId(location.href)||null;",
|
|
28
|
+
"var sidebarMeta=[];var metaById={};",
|
|
29
|
+
"var collectSidebarMeta=function(){sidebarMeta=[];metaById={};var nodes=[].slice.call(document.querySelectorAll('[href*=\"/app/\"]'));for(var li=0;li<nodes.length&&sidebarMeta.length<10;li++){var hr='';try{hr=nodes[li].getAttribute('href')||nodes[li].href||'';}catch(_){hr='';}var id=parseConversationId(hr);if(!id||metaById[id])continue;var tt='';try{tt=(nodes[li].innerText||nodes[li].textContent||'').replace(/\\s+/g,' ').trim();}catch(_){tt='';}if(tt.length>140)tt=tt.slice(0,140);var meta={id:id,title:tt||'Untitled'};sidebarMeta.push(meta);metaById[id]=meta;}if(curId&&!metaById[curId]){var curMeta={id:curId,title:getPageTitle()};sidebarMeta.unshift(curMeta);metaById[curId]=curMeta;}return sidebarMeta;};",
|
|
30
|
+
"for(var lookupAttempt=0;lookupAttempt<8&&!collectSidebarMeta().length;lookupAttempt++){setHint('Getting to know you...');await wait(350);}",
|
|
31
|
+
"var parseBatch=function(raw){var lines=String(raw||'').split('\\n');for(var i=0;i<lines.length;i++){var trimmed=(lines[i]||'').trim();if(!trimmed||/^\\d+$/.test(trimmed)||trimmed===\")]}'\")continue;try{var envelope=JSON.parse(trimmed);if(!Array.isArray(envelope))continue;for(var j=0;j<envelope.length;j++){var entry=envelope[j];if(Array.isArray(entry)&&entry[0]==='wrb.fr'&&typeof entry[2]==='string')return JSON.parse(entry[2]);}}catch(_){}}return null;};",
|
|
32
|
+
"var extractRpcMessages=function(data){var rows=(Array.isArray(data)&&Array.isArray(data[0]))?data[0]:[];var msgs=[];for(var ri=0;ri<rows.length;ri++){var row=rows[ri]||[];var u=row[2]&&row[2][0]&&row[2][0][0];var a=row[3]&&row[3][0]&&row[3][0][0]&&row[3][0][0][1]&&row[3][0][0][1][0];u=typeof u==='string'?clean(u):'';a=typeof a==='string'?clean(a):'';if(u)msgs.push({role:'user',content:u,timestamp:new Date().toISOString()});if(a)msgs.push({role:'assistant',content:a,timestamp:new Date().toISOString()});}return msgs;};",
|
|
33
|
+
"var fetchConversationRpc=async function(id){try{var wiz=window.WIZ_global_data||{};if(!wiz.SNlM0e||!wiz.cfb2h||!wiz.FdrFJe)return null;var freq=JSON.stringify([[['hNvQHb',JSON.stringify(['c_'+id,100,null,1,[0],[4],null,1]),null,'generic']]]);var body=new URLSearchParams({'f.req':freq,at:wiz.SNlM0e}).toString();var reqid=String(Date.now());if(reqid.length>6)reqid=reqid.slice(reqid.length-6);var url='/_/BardChatUi/data/batchexecute?rpcids=hNvQHb&source-path='+encodeURIComponent('/app/'+id)+'&bl='+encodeURIComponent(wiz.cfb2h||'')+'&f.sid='+encodeURIComponent(wiz.FdrFJe||'')+'&hl='+encodeURIComponent(document.documentElement.lang||navigator.language||'en')+'&_reqid='+reqid+'&rt=c';var res=await fetch(url,{method:'POST',credentials:'include',headers:{'content-type':'application/x-www-form-urlencoded;charset=UTF-8'},body:body});if(!res.ok)return null;var parsed=parseBatch(await res.text());var msgs=extractRpcMessages(parsed);return msgs&&msgs.length?msgs:null;}catch(_){return null;}};",
|
|
34
|
+
"var extractDomCurrent=function(){var domId=curId||('current_'+String(Date.now()).slice(-6));var userEls=[],modelEls=[];var uSels=['user-query .query-text','.query-text','user-query','[data-message-author-role=\"user\"]'];var mSels=['model-response .markdown','model-response .response-content','model-response','[data-message-author-role=\"model\"]'];for(var us=0;us<uSels.length;us++){userEls=[].slice.call(document.querySelectorAll(uSels[us]));if(userEls.length)break;}for(var ms=0;ms<mSels.length;ms++){modelEls=[].slice.call(document.querySelectorAll(mSels[ms]));if(modelEls.length)break;}var allEls=[];userEls.forEach(function(el){allEls.push({el:el,role:'user'})});modelEls.forEach(function(el){allEls.push({el:el,role:'assistant'})});allEls.sort(function(a,b){var pos=a.el.compareDocumentPosition(b.el);if(pos&Node.DOCUMENT_POSITION_FOLLOWING)return -1;if(pos&Node.DOCUMENT_POSITION_PRECEDING)return 1;return 0;});var msgs=[];for(var ai=0;ai<allEls.length;ai++){var t=clean(allEls[ai].el.innerText||allEls[ai].el.textContent||'');if(t&&t.length>1)msgs.push({role:allEls[ai].role,content:t,timestamp:new Date().toISOString()});}return msgs.length?{id:domId,title:getPageTitle(),messages:msgs}:null;};",
|
|
35
|
+
"var convos=[];var added={};",
|
|
36
|
+
"for(var si=0;si<sidebarMeta.length&&convos.length<10;si++){var meta=sidebarMeta[si];if(!meta||!meta.id||added[meta.id])continue;var progressText=(si%3===0)?'Understanding your conversations...':((si%3===1)?'Learning your patterns...':'Almost there...');setHint(progressText);var rpcMsgs=await fetchConversationRpc(meta.id);if(rpcMsgs&&rpcMsgs.length){convos.push({id:meta.id,title:meta.title||'Gemini Conversation',messages:rpcMsgs});added[meta.id]=1;}}",
|
|
37
|
+
"var domConv=extractDomCurrent();if(domConv&&domConv.messages&&domConv.messages.length&&!added[domConv.id]){convos.unshift(domConv);added[domConv.id]=1;}",
|
|
38
|
+
"for(var sm=0;sm<sidebarMeta.length&&convos.length<10;sm++){var meta=sidebarMeta[sm];if(!meta||!meta.id||added[meta.id])continue;convos.push({id:meta.id,title:meta.title||'Untitled',messages:[]});added[meta.id]=1;}",
|
|
39
|
+
|
|
40
|
+
"if(!convos.length){clearHint();alert('No Gemini conversations found. Open an existing Gemini chat or expand the left sidebar, then retry.');return;}",
|
|
41
|
+
|
|
42
|
+
"var data={type:'gemini-export-data',convos:convos,token:'__ONAIROS_TOKEN__',platform:'web-gemini'};",
|
|
43
|
+
"setHint('Almost there...');",
|
|
44
|
+
"var p=open(BRIDGE,'_dpSync','width=420,height=520');",
|
|
45
|
+
"if(!p){clearHint();alert('Allow popups and retry.');return;}",
|
|
46
|
+
"try{p.name='onairos-import:'+JSON.stringify({senderOrigin:APP_ORIGIN,payload:data});}catch(_){ }",
|
|
47
|
+
"clearHint();",
|
|
48
|
+
"var sendExport=function(){try{p.postMessage(data,BRIDGE_ORIGIN);return true;}catch(_){return false;}};",
|
|
49
|
+
|
|
50
|
+
"var onBridgeMessage=function(ev){",
|
|
51
|
+
"if(ev.source!==p)return;",
|
|
52
|
+
"var d=ev.data||{};",
|
|
53
|
+
"if(d.type==='llm-import-bridge-ready'){sendExport();return;}",
|
|
54
|
+
"if(d.type==='gemini-export-ack'){clearInterval(_iv);return;}",
|
|
55
|
+
"if(d.type==='llm-import-success'&&String(d.platform||'').indexOf('gemini')!==-1){clearHint();clearInterval(_iv);window.removeEventListener('message',onBridgeMessage);notifyApp({type:'llm-import-success',platform:'web-gemini',platformName:'Gemini'});try{window.close()}catch(_){}}",
|
|
56
|
+
"if(d.type==='llm-import-error'&&String(d.platform||'').indexOf('gemini')!==-1){clearHint();clearInterval(_iv);window.removeEventListener('message',onBridgeMessage);notifyApp({type:'llm-import-error',platform:'web-gemini',error:d.error||'Gemini import failed'});}};",
|
|
57
|
+
"window.addEventListener('message',onBridgeMessage);",
|
|
58
|
+
"var S=function(m){try{p.postMessage({type:'_dp_status',text:m},BRIDGE_ORIGIN)}catch(_){}};",
|
|
59
|
+
"S('Preparing Gemini import…');",
|
|
60
|
+
"var _att=0;var _iv=setInterval(function(){if(!p||p.closed){clearHint();clearInterval(_iv);window.removeEventListener('message',onBridgeMessage);return;}if(sendExport()&&_att===0)S('Sending Gemini export…');_att++;if(_att>120){clearHint();clearInterval(_iv);window.removeEventListener('message',onBridgeMessage);alert('Import bridge did not receive the Gemini export in time.');}},500);",
|
|
61
|
+
"}catch(e){try{clearHint()}catch(_){}alert('Export error: '+(e&&e.message?e.message:e));}})();",
|
|
62
|
+
].join('');
|
|
63
|
+
|
|
64
|
+
export const getOnairosGeminiBookmarklet = () => GEMINI_BOOKMARKLET_HREF;
|
|
65
|
+
|
|
66
|
+
// Persistent cross-tab listener: stores incoming export data in localStorage
|
|
67
|
+
// so the modal can pick it up even if it remounts after the message arrives.
|
|
68
|
+
const PENDING_IMPORT_KEY = '_pending_gemini_import';
|
|
69
|
+
const SYNC_SUCCESS_KEY = 'onairos_gemini_sync_success';
|
|
70
|
+
|
|
71
|
+
if (typeof window !== 'undefined') {
|
|
72
|
+
const _handleGeminiExport = (event) => {
|
|
73
|
+
if (event.data?.type === 'gemini-export-data') {
|
|
74
|
+
try {
|
|
75
|
+
localStorage.setItem(PENDING_IMPORT_KEY, JSON.stringify({
|
|
76
|
+
convos: event.data.convos,
|
|
77
|
+
receivedAt: Date.now()
|
|
78
|
+
}));
|
|
79
|
+
if (event.source) {
|
|
80
|
+
event.source.postMessage({ type: 'gemini-export-ack' }, event.origin);
|
|
81
|
+
}
|
|
82
|
+
} catch (_) { /* storage full or serialization error */ }
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
window.addEventListener('message', _handleGeminiExport);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default function ConnectGeminiModal({ open, onClose, onConnected }) {
|
|
89
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
90
|
+
const [copied, setCopied] = useState(false);
|
|
91
|
+
const [bookmarkletHrefFinal, setBookmarkletHrefFinal] = useState(() => {
|
|
92
|
+
if (typeof window === 'undefined') return '#';
|
|
93
|
+
const origin = window.location.origin;
|
|
94
|
+
const jwt = getUserToken() || '';
|
|
95
|
+
const bridgeUrl = (window.onairosImportBridgeUrl) || DEFAULT_IMPORT_BRIDGE_URL;
|
|
96
|
+
const bridgeOrigin = (() => { try { return new URL(bridgeUrl, origin).origin; } catch (_) { return origin; } })();
|
|
97
|
+
return GEMINI_BOOKMARKLET_HREF
|
|
98
|
+
.replace(/__ONAIROS_ORIGIN__/g, origin)
|
|
99
|
+
.replace('__ONAIROS_TOKEN__', jwt)
|
|
100
|
+
.replace('__BRIDGE_URL__', bridgeUrl)
|
|
101
|
+
.replace('__BRIDGE_ORIGIN__', bridgeOrigin);
|
|
102
|
+
});
|
|
103
|
+
const [mobileCodeFinal, setMobileCodeFinal] = useState('#');
|
|
104
|
+
const syncTimeoutRef = useRef(null);
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
setIsMobile(window.innerWidth <= 768);
|
|
108
|
+
const handleResize = () => setIsMobile(window.innerWidth <= 768);
|
|
109
|
+
window.addEventListener('resize', handleResize);
|
|
110
|
+
return () => {
|
|
111
|
+
if (typeof handleResize === 'function') {
|
|
112
|
+
window.removeEventListener('resize', handleResize);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}, []);
|
|
116
|
+
|
|
117
|
+
// Embed origin, token, and bridge URL into the bookmarklet when modal opens
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (!open) return () => {};
|
|
120
|
+
const origin = window.location.origin;
|
|
121
|
+
const jwt = getUserToken() || '';
|
|
122
|
+
const bridgeUrl = (typeof window !== 'undefined' && window.onairosImportBridgeUrl) || DEFAULT_IMPORT_BRIDGE_URL;
|
|
123
|
+
const bridgeOrigin = (() => {
|
|
124
|
+
try {
|
|
125
|
+
return new URL(bridgeUrl, origin).origin;
|
|
126
|
+
} catch (_) {
|
|
127
|
+
return origin;
|
|
128
|
+
}
|
|
129
|
+
})();
|
|
130
|
+
const href = GEMINI_BOOKMARKLET_HREF
|
|
131
|
+
.replace(/__ONAIROS_ORIGIN__/g, origin)
|
|
132
|
+
.replace('__ONAIROS_TOKEN__', jwt)
|
|
133
|
+
.replace('__BRIDGE_URL__', bridgeUrl)
|
|
134
|
+
.replace('__BRIDGE_ORIGIN__', bridgeOrigin);
|
|
135
|
+
setBookmarkletHrefFinal(href);
|
|
136
|
+
setMobileCodeFinal(href);
|
|
137
|
+
}, [open]);
|
|
138
|
+
|
|
139
|
+
// Core state management + message handling + polling
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!open) return () => {};
|
|
142
|
+
const baseUrl = (typeof window !== 'undefined' && window.onairosBaseUrl) || getApiBaseUrl();
|
|
143
|
+
const apiKey = getApiKey();
|
|
144
|
+
|
|
145
|
+
const getIdentifierForAccountCheck = () => {
|
|
146
|
+
try {
|
|
147
|
+
const user = JSON.parse(localStorage.getItem('onairosUser') || '{}');
|
|
148
|
+
return (
|
|
149
|
+
user.email ||
|
|
150
|
+
user.userEmail ||
|
|
151
|
+
user.identifier ||
|
|
152
|
+
user.userName ||
|
|
153
|
+
user.username ||
|
|
154
|
+
localStorage.getItem('onairos_user_email') ||
|
|
155
|
+
null
|
|
156
|
+
);
|
|
157
|
+
} catch (_) {
|
|
158
|
+
return localStorage.getItem('onairos_user_email') || null;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const isGeminiConnectedFromAccountStatus = (data) => {
|
|
163
|
+
try {
|
|
164
|
+
const acct = data?.AccountInfo?.accounts?.gemini;
|
|
165
|
+
if (acct?.connected === true) return true;
|
|
166
|
+
const connectedPlatforms = data?.accountStatus?.connectedPlatforms;
|
|
167
|
+
if (Array.isArray(connectedPlatforms)) {
|
|
168
|
+
return connectedPlatforms.some((p) => String(p).toLowerCase().includes('gemini'));
|
|
169
|
+
}
|
|
170
|
+
const connections = data?.AccountInfo?.connections;
|
|
171
|
+
if (Array.isArray(connections)) {
|
|
172
|
+
return connections.some((p) => String(p).toLowerCase().includes('gemini'));
|
|
173
|
+
}
|
|
174
|
+
if (connections && typeof connections === 'object') {
|
|
175
|
+
return connections.Gemini || connections.gemini || false;
|
|
176
|
+
}
|
|
177
|
+
} catch (_) {
|
|
178
|
+
// ignore
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const markConnectedLocallyAndClose = () => {
|
|
184
|
+
if (syncTimeoutRef.current) {
|
|
185
|
+
window.clearTimeout(syncTimeoutRef.current);
|
|
186
|
+
syncTimeoutRef.current = null;
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
const storedConnections = JSON.parse(localStorage.getItem('onairos_connected_accounts') || '{}');
|
|
190
|
+
if (!storedConnections.Gemini) {
|
|
191
|
+
storedConnections.Gemini = true;
|
|
192
|
+
localStorage.setItem('onairos_connected_accounts', JSON.stringify(storedConnections));
|
|
193
|
+
}
|
|
194
|
+
} catch (_) {}
|
|
195
|
+
try {
|
|
196
|
+
const connectedAccounts = JSON.parse(localStorage.getItem('connectedAccounts') || '[]');
|
|
197
|
+
if (!connectedAccounts.includes('Gemini')) {
|
|
198
|
+
connectedAccounts.push('Gemini');
|
|
199
|
+
localStorage.setItem('connectedAccounts', JSON.stringify(connectedAccounts));
|
|
200
|
+
}
|
|
201
|
+
} catch (_) {}
|
|
202
|
+
try {
|
|
203
|
+
const userData = JSON.parse(localStorage.getItem('onairosUser') || '{}');
|
|
204
|
+
if (!Array.isArray(userData.connectedAccounts)) userData.connectedAccounts = [];
|
|
205
|
+
if (!userData.connectedAccounts.includes('Gemini')) {
|
|
206
|
+
userData.connectedAccounts.push('Gemini');
|
|
207
|
+
localStorage.setItem('onairosUser', JSON.stringify(userData));
|
|
208
|
+
}
|
|
209
|
+
} catch (_) {}
|
|
210
|
+
// Dispatch event so other components (icon toggles, dashboards) can react
|
|
211
|
+
try {
|
|
212
|
+
window.dispatchEvent(new CustomEvent('connected-accounts-updated', { detail: { platform: 'Gemini' } }));
|
|
213
|
+
} catch (_) {}
|
|
214
|
+
try {
|
|
215
|
+
localStorage.removeItem(SYNC_SUCCESS_KEY);
|
|
216
|
+
} catch (_) {}
|
|
217
|
+
|
|
218
|
+
if (typeof onConnected === 'function') onConnected();
|
|
219
|
+
if (typeof onClose === 'function') onClose();
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// Upload extracted data from the app's own origin
|
|
223
|
+
const uploadExportData = async (convos) => {
|
|
224
|
+
try {
|
|
225
|
+
const userData = JSON.parse(localStorage.getItem('onairosUser') || '{}');
|
|
226
|
+
const jwt = userData.token || localStorage.getItem('onairos_user_token');
|
|
227
|
+
if (!jwt) return;
|
|
228
|
+
const resp = await fetch(`${baseUrl}/gemini-sync`, {
|
|
229
|
+
method: 'POST',
|
|
230
|
+
headers: { 'Content-Type': 'application/json' },
|
|
231
|
+
body: JSON.stringify({ data: JSON.stringify({ convos, token: jwt }) })
|
|
232
|
+
});
|
|
233
|
+
if (resp.ok) {
|
|
234
|
+
markConnectedLocallyAndClose();
|
|
235
|
+
}
|
|
236
|
+
} catch (_) { /* upload failed; polling will retry */ }
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// Process a pending import and upload
|
|
240
|
+
const processPendingImport = (raw) => {
|
|
241
|
+
try {
|
|
242
|
+
const { convos } = JSON.parse(raw);
|
|
243
|
+
uploadExportData(convos);
|
|
244
|
+
} catch (_) {}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// Check for pending import data left by the module-level listener
|
|
248
|
+
const pendingRaw = localStorage.getItem(PENDING_IMPORT_KEY);
|
|
249
|
+
if (pendingRaw) {
|
|
250
|
+
localStorage.removeItem(PENDING_IMPORT_KEY);
|
|
251
|
+
processPendingImport(pendingRaw);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Poll localStorage for pending imports (catches data arriving while modal is mounted)
|
|
255
|
+
const pollInterval = setInterval(() => {
|
|
256
|
+
const raw = localStorage.getItem(PENDING_IMPORT_KEY);
|
|
257
|
+
if (raw) {
|
|
258
|
+
localStorage.removeItem(PENDING_IMPORT_KEY);
|
|
259
|
+
processPendingImport(raw);
|
|
260
|
+
}
|
|
261
|
+
}, 1000);
|
|
262
|
+
|
|
263
|
+
const connectionCheck = setInterval(() => {
|
|
264
|
+
try {
|
|
265
|
+
const storedConnections = JSON.parse(localStorage.getItem('onairos_connected_accounts') || '{}');
|
|
266
|
+
const geminiSyncSuccess = localStorage.getItem(SYNC_SUCCESS_KEY);
|
|
267
|
+
if (storedConnections.gemini || storedConnections.Gemini || geminiSyncSuccess === 'true') {
|
|
268
|
+
markConnectedLocallyAndClose();
|
|
269
|
+
clearInterval(connectionCheck);
|
|
270
|
+
clearInterval(backendPoll);
|
|
271
|
+
}
|
|
272
|
+
} catch (_) {
|
|
273
|
+
// ignore
|
|
274
|
+
}
|
|
275
|
+
}, 1000);
|
|
276
|
+
|
|
277
|
+
let backendPollInFlight = false;
|
|
278
|
+
const backendPoll = setInterval(async () => {
|
|
279
|
+
if (!open || backendPollInFlight) return;
|
|
280
|
+
const identifier = getIdentifierForAccountCheck();
|
|
281
|
+
if (!identifier) return;
|
|
282
|
+
|
|
283
|
+
backendPollInFlight = true;
|
|
284
|
+
try {
|
|
285
|
+
const resp = await fetch(`${baseUrl}/getAccountInfo/email`, {
|
|
286
|
+
method: 'POST',
|
|
287
|
+
headers: {
|
|
288
|
+
'Content-Type': 'application/json',
|
|
289
|
+
'x-api-key': apiKey,
|
|
290
|
+
},
|
|
291
|
+
body: JSON.stringify({ Info: { identifier: String(identifier).trim().toLowerCase() } }),
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
if (resp.ok) {
|
|
295
|
+
const data = await resp.json();
|
|
296
|
+
if (isGeminiConnectedFromAccountStatus(data)) {
|
|
297
|
+
clearInterval(connectionCheck);
|
|
298
|
+
clearInterval(backendPoll);
|
|
299
|
+
markConnectedLocallyAndClose();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
} catch (_) {
|
|
303
|
+
// non-fatal; keep polling
|
|
304
|
+
} finally {
|
|
305
|
+
backendPollInFlight = false;
|
|
306
|
+
}
|
|
307
|
+
}, 2000);
|
|
308
|
+
|
|
309
|
+
// Direct postMessage handler (fastest path when modal is mounted)
|
|
310
|
+
const handleMessage = (event) => {
|
|
311
|
+
if (event.data?.type === 'gemini-export-data') {
|
|
312
|
+
const { convos } = event.data;
|
|
313
|
+
localStorage.removeItem(PENDING_IMPORT_KEY);
|
|
314
|
+
if (event.source) {
|
|
315
|
+
try { event.source.postMessage({ type: 'gemini-export-ack' }, event.origin); } catch (_) {}
|
|
316
|
+
}
|
|
317
|
+
uploadExportData(convos);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (event.data?.type === 'llm-import-success' && String(event.data.platform || '').includes('gemini')) {
|
|
321
|
+
markConnectedLocallyAndClose();
|
|
322
|
+
clearInterval(connectionCheck);
|
|
323
|
+
clearInterval(backendPoll);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
window.addEventListener('message', handleMessage);
|
|
327
|
+
|
|
328
|
+
return () => {
|
|
329
|
+
if (typeof handleMessage === 'function') {
|
|
330
|
+
window.removeEventListener('message', handleMessage);
|
|
331
|
+
}
|
|
332
|
+
clearInterval(pollInterval);
|
|
333
|
+
clearInterval(connectionCheck);
|
|
334
|
+
clearInterval(backendPoll);
|
|
335
|
+
if (syncTimeoutRef.current) {
|
|
336
|
+
window.clearTimeout(syncTimeoutRef.current);
|
|
337
|
+
syncTimeoutRef.current = null;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
}, [open, onConnected, onClose]);
|
|
341
|
+
|
|
342
|
+
const handleCopyCode = () => {
|
|
343
|
+
navigator.clipboard.writeText(mobileCodeFinal);
|
|
344
|
+
setCopied(true);
|
|
345
|
+
setTimeout(() => setCopied(false), 2000);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const handleGotIt = () => {
|
|
349
|
+
if (typeof onConnected === 'function') onConnected();
|
|
350
|
+
if (typeof onClose === 'function') onClose();
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
if (!open) return null;
|
|
354
|
+
|
|
355
|
+
return ReactDOM.createPortal(
|
|
356
|
+
<div style={{ position: 'fixed', inset: 0, zIndex: 2147483647, pointerEvents: 'auto' }}>
|
|
357
|
+
<style>{`
|
|
358
|
+
@keyframes gentlePulse {
|
|
359
|
+
0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.35); }
|
|
360
|
+
50% { box-shadow: 0 0 0 10px rgba(139, 92, 246, 0); }
|
|
361
|
+
}
|
|
362
|
+
.bookmarklet-button {
|
|
363
|
+
background: rgba(15, 23, 42, 0.85);
|
|
364
|
+
border-radius: 9999px;
|
|
365
|
+
border: 1px solid rgba(255,255,255,0.16);
|
|
366
|
+
backdrop-filter: blur(18px);
|
|
367
|
+
}
|
|
368
|
+
.bookmarklet-button:hover { background: rgba(15, 23, 42, 0.92); }
|
|
369
|
+
@keyframes fadeInScale {
|
|
370
|
+
0% { opacity: 0; transform: translateY(8px) scale(0.96); }
|
|
371
|
+
100% { opacity: 1; transform: translateY(0) scale(1); }
|
|
372
|
+
}
|
|
373
|
+
.gemini-modal-card { animation: fadeInScale 200ms cubic-bezier(0.16, 1, 0.3, 1); }
|
|
374
|
+
.step-circle {
|
|
375
|
+
background: rgba(15, 23, 42, 0.9);
|
|
376
|
+
min-width: 28px;
|
|
377
|
+
width: 28px;
|
|
378
|
+
height: 28px;
|
|
379
|
+
}
|
|
380
|
+
.gemini-got-it-button {
|
|
381
|
+
color: #FFFFFF !important;
|
|
382
|
+
background-color: rgba(15, 23, 42, 0.8) !important;
|
|
383
|
+
}
|
|
384
|
+
.gemini-got-it-button:hover { background-color: rgba(15, 23, 42, 0.9) !important; }
|
|
385
|
+
.gemini-got-it-button * { color: #FFFFFF !important; }
|
|
386
|
+
@media (max-width: 768px) {
|
|
387
|
+
.gemini-modal-backdrop { align-items: flex-end !important; padding: 0 !important; }
|
|
388
|
+
.gemini-modal-card {
|
|
389
|
+
max-width: 100% !important;
|
|
390
|
+
height: 90vh !important;
|
|
391
|
+
max-height: 90vh !important;
|
|
392
|
+
border-radius: 24px 24px 0 0 !important;
|
|
393
|
+
animation: slideUpFromBottom 300ms cubic-bezier(0.16, 1, 0.3, 1) !important;
|
|
394
|
+
display: flex;
|
|
395
|
+
flex-direction: column;
|
|
396
|
+
}
|
|
397
|
+
.gemini-modal-content { overflow-y: auto; flex: 1; }
|
|
398
|
+
}
|
|
399
|
+
@keyframes slideUpFromBottom {
|
|
400
|
+
0% { transform: translateY(100%); }
|
|
401
|
+
100% { transform: translateY(0); }
|
|
402
|
+
}
|
|
403
|
+
`}</style>
|
|
404
|
+
|
|
405
|
+
<div
|
|
406
|
+
className="gemini-modal-backdrop fixed inset-0 flex items-center justify-center p-4 bg-black/60"
|
|
407
|
+
style={{ zIndex: 2147483647 }}
|
|
408
|
+
>
|
|
409
|
+
<div
|
|
410
|
+
className="gemini-modal-card w-full max-w-md rounded-3xl shadow-2xl border border-white/10 overflow-hidden text-white relative"
|
|
411
|
+
style={{
|
|
412
|
+
background:
|
|
413
|
+
'linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.92) 50%, rgba(15, 23, 42, 0.95) 100%)',
|
|
414
|
+
boxShadow:
|
|
415
|
+
'inset 0 1px 0 0 rgba(255, 255, 255, 0.1), 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 100px rgba(139, 92, 246, 0.15)',
|
|
416
|
+
}}
|
|
417
|
+
>
|
|
418
|
+
<div className="relative px-5 py-4 border-b border-white/10 bg-white/5 flex-shrink-0">
|
|
419
|
+
<button
|
|
420
|
+
onClick={onClose}
|
|
421
|
+
aria-label="Close"
|
|
422
|
+
type="button"
|
|
423
|
+
className="onairos-close-btn absolute right-3 top-3 inline-flex items-center justify-center rounded-full transition-all hover:scale-105 z-50 cursor-pointer"
|
|
424
|
+
style={{
|
|
425
|
+
width: 28,
|
|
426
|
+
height: 28,
|
|
427
|
+
padding: 0,
|
|
428
|
+
background: 'rgba(255, 255, 255, 0.08)',
|
|
429
|
+
border: '1px solid rgba(255, 255, 255, 0.18)',
|
|
430
|
+
backdropFilter: 'blur(8px)',
|
|
431
|
+
WebkitBackdropFilter: 'blur(8px)',
|
|
432
|
+
color: '#ffffff',
|
|
433
|
+
}}
|
|
434
|
+
onMouseEnter={(e) => { e.currentTarget.style.background = 'rgba(255,255,255,0.16)'; }}
|
|
435
|
+
onMouseLeave={(e) => { e.currentTarget.style.background = 'rgba(255,255,255,0.08)'; }}
|
|
436
|
+
>
|
|
437
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden>
|
|
438
|
+
<path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
439
|
+
</svg>
|
|
440
|
+
</button>
|
|
441
|
+
|
|
442
|
+
<h2 className="text-xl font-semibold pr-8 text-white">{isMobile ? 'Export Gemini' : 'Connect Gemini'}</h2>
|
|
443
|
+
<p className="text-sm mt-0.5 text-white">Three quick steps to export your conversation.</p>
|
|
444
|
+
|
|
445
|
+
<div className="mt-3 flex items-start gap-2 bg-white/12 rounded-2xl px-3 py-2">
|
|
446
|
+
<svg className="w-4 h-4 text-violet-300 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
|
447
|
+
<path
|
|
448
|
+
fillRule="evenodd"
|
|
449
|
+
d="M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
|
|
450
|
+
clipRule="evenodd"
|
|
451
|
+
/>
|
|
452
|
+
</svg>
|
|
453
|
+
<p className="text-xs leading-relaxed text-white">
|
|
454
|
+
<strong className="font-semibold">Private.</strong> This bookmarklet runs entirely in your browser.
|
|
455
|
+
</p>
|
|
456
|
+
</div>
|
|
457
|
+
</div>
|
|
458
|
+
|
|
459
|
+
<div className="px-5 py-4 space-y-4 gemini-modal-content">
|
|
460
|
+
{isMobile ? (
|
|
461
|
+
<>
|
|
462
|
+
<div className="flex gap-3">
|
|
463
|
+
<div className="flex-shrink-0">
|
|
464
|
+
<div className="step-circle rounded-full flex items-center justify-center">
|
|
465
|
+
<span className="text-white font-bold text-sm">1</span>
|
|
466
|
+
</div>
|
|
467
|
+
</div>
|
|
468
|
+
<div className="flex-1 pt-0.5">
|
|
469
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Copy the bookmark code</h3>
|
|
470
|
+
<button
|
|
471
|
+
onClick={handleCopyCode}
|
|
472
|
+
className="mt-1 w-full flex items-center justify-center gap-2 py-3 bg-white/10 rounded-xl text-sm font-medium hover:bg-white/20 active:scale-95 transition-all text-violet-200 border border-violet-500/30"
|
|
473
|
+
>
|
|
474
|
+
{copied ? 'Copied' : 'Copy code'}
|
|
475
|
+
</button>
|
|
476
|
+
</div>
|
|
477
|
+
</div>
|
|
478
|
+
|
|
479
|
+
<div className="border-t border-white/10 ml-10" />
|
|
480
|
+
|
|
481
|
+
<div className="flex gap-3">
|
|
482
|
+
<div className="flex-shrink-0">
|
|
483
|
+
<div className="step-circle rounded-full flex items-center justify-center">
|
|
484
|
+
<span className="text-white font-bold text-sm">2</span>
|
|
485
|
+
</div>
|
|
486
|
+
</div>
|
|
487
|
+
<div className="flex-1 pt-0.5">
|
|
488
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Create bookmark</h3>
|
|
489
|
+
<p className="text-xs text-slate-200 leading-relaxed mb-2">
|
|
490
|
+
1. Open browser menu
|
|
491
|
+
<br />
|
|
492
|
+
2. Add Bookmark (name it "Export Gemini")
|
|
493
|
+
<br />
|
|
494
|
+
3. Edit the bookmark URL and paste the code
|
|
495
|
+
</p>
|
|
496
|
+
</div>
|
|
497
|
+
</div>
|
|
498
|
+
|
|
499
|
+
<div className="border-t border-white/10 ml-10" />
|
|
500
|
+
|
|
501
|
+
<div className="flex gap-3">
|
|
502
|
+
<div className="flex-shrink-0">
|
|
503
|
+
<div className="step-circle rounded-full flex items-center justify-center">
|
|
504
|
+
<span className="text-white font-bold text-sm">3</span>
|
|
505
|
+
</div>
|
|
506
|
+
</div>
|
|
507
|
+
<div className="flex-1 pt-0.5">
|
|
508
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Run it on Gemini</h3>
|
|
509
|
+
<button
|
|
510
|
+
onClick={() => window.open('https://gemini.google.com', '_blank')}
|
|
511
|
+
className="mt-2 text-xs bg-violet-600 hover:bg-violet-500 text-white px-3 py-1.5 rounded-lg inline-flex items-center gap-1"
|
|
512
|
+
>
|
|
513
|
+
Open Gemini
|
|
514
|
+
</button>
|
|
515
|
+
<p className="text-xs text-slate-300 mt-2">Tap the bookmark to export your conversation.</p>
|
|
516
|
+
</div>
|
|
517
|
+
</div>
|
|
518
|
+
</>
|
|
519
|
+
) : (
|
|
520
|
+
<>
|
|
521
|
+
<div className="flex gap-3">
|
|
522
|
+
<div className="flex-shrink-0">
|
|
523
|
+
<div className="step-circle rounded-full flex items-center justify-center">
|
|
524
|
+
<span className="text-white font-bold text-sm">1</span>
|
|
525
|
+
</div>
|
|
526
|
+
</div>
|
|
527
|
+
<div className="flex-1 pt-0.5">
|
|
528
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Drag this button to your bookmarks bar</h3>
|
|
529
|
+
<div className="relative inline-block mt-2">
|
|
530
|
+
<div className="absolute inset-0 rounded-full" style={{ animation: 'gentlePulse 2s ease-in-out infinite' }} />
|
|
531
|
+
<a
|
|
532
|
+
href={bookmarkletHrefFinal}
|
|
533
|
+
title="Export Gemini"
|
|
534
|
+
draggable="true"
|
|
535
|
+
onDragStart={(e) => {
|
|
536
|
+
try {
|
|
537
|
+
const bookmarkTitle = 'Export Gemini';
|
|
538
|
+
const html = `<a href="${bookmarkletHrefFinal}">${bookmarkTitle}</a>`;
|
|
539
|
+
e.dataTransfer.setData('text/uri-list', bookmarkletHrefFinal);
|
|
540
|
+
e.dataTransfer.setData('text/plain', bookmarkletHrefFinal);
|
|
541
|
+
e.dataTransfer.setData('text/html', html);
|
|
542
|
+
e.dataTransfer.setData('text/x-moz-url', `${bookmarkletHrefFinal}\n${bookmarkTitle}`);
|
|
543
|
+
e.dataTransfer.setData('DownloadURL', `application/javascript:${bookmarkTitle}:${bookmarkletHrefFinal}`);
|
|
544
|
+
e.dataTransfer.effectAllowed = 'copy';
|
|
545
|
+
} catch (err) {
|
|
546
|
+
console.warn('Drag start error:', err);
|
|
547
|
+
}
|
|
548
|
+
}}
|
|
549
|
+
onClick={(e) => {
|
|
550
|
+
e.preventDefault();
|
|
551
|
+
alert(
|
|
552
|
+
'Please drag this button to your bookmarks bar.\n\nTip: Press Ctrl+Shift+B (or Cmd+Shift+B on Mac) to show your bookmarks bar.'
|
|
553
|
+
);
|
|
554
|
+
}}
|
|
555
|
+
className="bookmarklet-button relative inline-flex items-center gap-1.5 px-4 py-2 font-medium cursor-move select-none transition-all hover:scale-[1.03]"
|
|
556
|
+
suppressHydrationWarning
|
|
557
|
+
>
|
|
558
|
+
<span className="text-base">✨</span>
|
|
559
|
+
<span className="text-sm">Export Gemini</span>
|
|
560
|
+
</a>
|
|
561
|
+
</div>
|
|
562
|
+
<p className="text-[11px] mt-2 text-slate-300">
|
|
563
|
+
If it saves with a blank name, right‑click it → <span className="font-semibold text-slate-100">Rename</span> → set it to{' '}
|
|
564
|
+
<span className="font-semibold text-slate-100">Export Gemini</span>.
|
|
565
|
+
</p>
|
|
566
|
+
<p className="text-xs mt-2 text-slate-200">
|
|
567
|
+
<kbd className="px-1.5 py-0.5 bg-white/10 rounded-full text-[10px] font-mono border border-white/10 text-slate-50">
|
|
568
|
+
Ctrl+Shift+B
|
|
569
|
+
</kbd>{' '}
|
|
570
|
+
(or{' '}
|
|
571
|
+
<kbd className="px-1.5 py-0.5 bg-white/10 rounded-full text-[10px] font-mono border border-white/10 text-slate-50">
|
|
572
|
+
Cmd+Shift+B
|
|
573
|
+
</kbd>{' '}
|
|
574
|
+
on Mac) to show bookmarks bar
|
|
575
|
+
</p>
|
|
576
|
+
</div>
|
|
577
|
+
</div>
|
|
578
|
+
|
|
579
|
+
<div className="border-t border-white/10 ml-10" />
|
|
580
|
+
|
|
581
|
+
<div className="flex gap-3">
|
|
582
|
+
<div className="flex-shrink-0">
|
|
583
|
+
<div className="step-circle rounded-full flex items-center justify-center">
|
|
584
|
+
<span className="text-white font-bold text-sm">2</span>
|
|
585
|
+
</div>
|
|
586
|
+
</div>
|
|
587
|
+
<div className="flex-1 pt-0.5">
|
|
588
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Open Gemini and log in</h3>
|
|
589
|
+
<p className="text-xs mb-2 text-slate-200">Make sure you're logged into your Gemini account</p>
|
|
590
|
+
<button
|
|
591
|
+
type="button"
|
|
592
|
+
onClick={() => window.open('https://gemini.google.com', '_blank')}
|
|
593
|
+
className="inline-flex items-center gap-1.5 px-4 py-2 rounded-full text-xs font-medium transition-all hover:scale-[1.02] active:scale-[0.98]"
|
|
594
|
+
style={{
|
|
595
|
+
background: 'linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%)',
|
|
596
|
+
color: '#ffffff',
|
|
597
|
+
boxShadow: '0 0 25px rgba(139, 92, 246, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2)',
|
|
598
|
+
}}
|
|
599
|
+
>
|
|
600
|
+
Open Gemini
|
|
601
|
+
</button>
|
|
602
|
+
</div>
|
|
603
|
+
</div>
|
|
604
|
+
|
|
605
|
+
<div className="border-t border-white/10 ml-10" />
|
|
606
|
+
|
|
607
|
+
<div className="flex gap-3">
|
|
608
|
+
<div className="flex-shrink-0">
|
|
609
|
+
<div className="step-circle rounded-full flex items-center justify-center">
|
|
610
|
+
<span className="text-white font-bold text-sm">3</span>
|
|
611
|
+
</div>
|
|
612
|
+
</div>
|
|
613
|
+
<div className="flex-1 pt-0.5">
|
|
614
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Click the bookmark on Gemini</h3>
|
|
615
|
+
<p className="text-xs text-slate-200">
|
|
616
|
+
Open a chat (URL like <strong className="text-white">/app/<id></strong>) and click the{' '}
|
|
617
|
+
<strong className="text-white">"Export Gemini"</strong> bookmark.
|
|
618
|
+
</p>
|
|
619
|
+
</div>
|
|
620
|
+
</div>
|
|
621
|
+
</>
|
|
622
|
+
)}
|
|
623
|
+
</div>
|
|
624
|
+
|
|
625
|
+
<div className="px-5 py-4 bg-white/5 border-t border-white/10 flex-shrink-0">
|
|
626
|
+
<button
|
|
627
|
+
type="button"
|
|
628
|
+
onClick={handleGotIt}
|
|
629
|
+
className="w-full px-4 py-2.5 rounded-full font-medium text-sm transition-all hover:scale-[1.01] active:scale-[0.99] shadow-[0_10px_30px_rgba(15,23,42,0.45)] border border-white/40 gemini-got-it-button"
|
|
630
|
+
>
|
|
631
|
+
<span>{isMobile ? 'Close' : 'Got it!'}</span>
|
|
632
|
+
</button>
|
|
633
|
+
</div>
|
|
634
|
+
</div>
|
|
635
|
+
</div>
|
|
636
|
+
</div>,
|
|
637
|
+
document.body
|
|
638
|
+
);
|
|
639
|
+
}
|