From 8d84dc8a7614749c5312bb3b2b7f6e60ed540e3a Mon Sep 17 00:00:00 2001 From: David Guilherme Date: Wed, 29 Apr 2015 21:18:12 -0300 Subject: [PATCH] Communicate with translate api --- app/main.js | 10 ++++++++++ manifest.json | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/main.js b/app/main.js index 4129f44..ca8ce40 100644 --- a/app/main.js +++ b/app/main.js @@ -11,4 +11,14 @@ document.addEventListener("DOMContentLoaded", function(event) { chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { console.log(request.selectedText); + + req = new XMLHttpRequest(); + req.open('GET', 'http://localhost:8000/translate.json', true); + req.onreadystatechange = function () { + if (req.readyState == 4) { + console.log(JSON.parse(req.responseText)); + } + }; + + req.send(); }); diff --git a/manifest.json b/manifest.json index 0b19724..05a3242 100644 --- a/manifest.json +++ b/manifest.json @@ -11,7 +11,8 @@ }, "permissions": [ - "contextMenus" + "contextMenus", + "http://localhost:8000/" ], "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" -- libgit2 0.21.2