私のブックマークの拡張機能では、ブックマークを "所有者"としてユーザーにデータベースに書き込むために、ユーザーのGmailアドレスをGoogleのアプリケーションエンジンに送信する必要があります。誰かがエクステンションをインストールしたときに、変数としてユーザーメールを保存するにはどうすればよいですか?
私はバックグラウンドページを持っているのでポップアップを使用できないことを理解しています(私はこれについて読むことを覚えていますが、もう一度それを見つけることはできませんでした)。私はChromeストアのインストールプロセスも読んでいます。誰かが私をドキュメントの正しい場所に誘導できるのであれば、私は感謝します。
下記の変数extension_user
を含むbackground.html
をコピーします。拡張機能をアップロードするときにこの変数をユーザーから取得するにはどうすればよいですか? 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>