//var assistant_url="http://127.0.0.1:7860/assistant/"; var assistant_url="https://llmbb-llmbb-agent.hf.space/assistant"; document.addEventListener('DOMContentLoaded', function() { chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) { var currentUrl = tabs[0].url; chrome.storage.local.get(['access_token'], function(result) { if (result.access_token) { console.log('access_token currently is ' + result.access_token); var iframe = document.createElement('iframe'); iframe.src = assistant_url + "?access_token="+result.access_token+"&url=" + currentUrl; iframe.height = '570px'; // iframe.sandbox = 'allow-same-origin allow-scripts'; // iframe.allow = "geolocation *;"; var iframe_area = document.getElementById('iframe_area') iframe_area.appendChild(iframe); }else{ chrome.notifications.create("access_token", { type: 'basic', iconUrl: 'img/popup.png', title: 'access token', message: 'access token is not valid!' }); } }); // chrome.runtime.sendMessage({ data: currentUrl , close: true , flag: 'open_popup_and_send_url_from_popup'}); }); // setTimeout(function() { // console.log('This message will be logged after 0.5 second'); // var popup_url=''; // chrome.storage.local.get(['access_token'], function(result) { // if (result.access_token) { // console.log('access_token currently is ' + result.access_token); // popup_url = "https://llmbb-llmbb-agent.hf.space/?access_token="+result.access_token; // var iframe = document.createElement('iframe'); // iframe.src = popup_url; // iframe.height = '570px'; // // iframe.sandbox = 'allow-same-origin allow-scripts'; // // iframe.allow = "geolocation *;"; // var iframe_area = document.getElementById('iframe_area') // iframe_area.appendChild(iframe); // } // }); // }, 500); }) document.getElementById('set_access_token').addEventListener('click', function() { var access_token = document.getElementById('access_token').value; // save config chrome.storage.local.set({access_token: access_token}, function() { console.log('access_token is set to ' + access_token); chrome.notifications.create("set_access_token", { type: 'basic', iconUrl: 'img/popup.png', title: 'set access token', message: 'set access token success, please reopen this extension!' }); // chrome.runtime.sendMessage({ data: access_token , close: true , flag: 'set_access_token'}); document.getElementById('access_token').value = ''; }); })