In my bookmark extension, I need to send the user's gmail address to the Google engine in order to write the bookmark to the database as the user as the "owner".
I understand that I cannot use the popup because I have a help page (I remember reading about it, but I could not find it again). I also read the installation process in the Chrome store. I would appreciate it if anyone could direct me to the right place in the documentation.
I will copy background.html
below with the extension_user
variable enabled. How to get this variable from the user when loading the extension? This is my previous question .
<html> <script> chrome.browserAction.onClicked.addListener(function(tab) { chrome.tabs.getSelected(null, function(tab) { // Send a request to the content script. chrome.tabs.sendRequest(tab.id, {action: "getDOM"}, function(response) { var firstParagraph = response.dom; var formData = new FormData(); formData.append("url", tab.url); formData.append("title", tab.title); formData.append("pitch", firstParagraph); //***the variable with user email to send to backend:***// //formData.append("extension_user", extension_user) var xhr = new XMLHttpRequest(); xhr.open("POST", "http://ting-1.appspot.com/submithandlertest", true); xhr.onreadystatechange = function (aEvt) { if (xhr.readyState == 4) { if (xhr.status == 200){ console.log("request 200-OK"); chrome.browserAction.setBadgeText ( { text: "done" } ); setTimeout(function () { chrome.browserAction.setBadgeText( { text: "" } ); }, 2000); }else{ console.log("connection error"); chrome.browserAction.setBadgeText ( { text: "ERR" } ); } } }; xhr.send(formData); }); //chrome.tabs.sendRequest }); }); </script> </html>
source share