Commit 8d84dc8a7614749c5312bb3b2b7f6e60ed540e3a
1 parent
02d2f40a
Exists in
master
Communicate with translate api
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
app/main.js
@@ -11,4 +11,14 @@ document.addEventListener("DOMContentLoaded", function(event) { | @@ -11,4 +11,14 @@ document.addEventListener("DOMContentLoaded", function(event) { | ||
11 | chrome.runtime.onMessage.addListener( | 11 | chrome.runtime.onMessage.addListener( |
12 | function(request, sender, sendResponse) { | 12 | function(request, sender, sendResponse) { |
13 | console.log(request.selectedText); | 13 | console.log(request.selectedText); |
14 | + | ||
15 | + req = new XMLHttpRequest(); | ||
16 | + req.open('GET', 'http://localhost:8000/translate.json', true); | ||
17 | + req.onreadystatechange = function () { | ||
18 | + if (req.readyState == 4) { | ||
19 | + console.log(JSON.parse(req.responseText)); | ||
20 | + } | ||
21 | + }; | ||
22 | + | ||
23 | + req.send(); | ||
14 | }); | 24 | }); |
manifest.json
@@ -11,7 +11,8 @@ | @@ -11,7 +11,8 @@ | ||
11 | }, | 11 | }, |
12 | 12 | ||
13 | "permissions": [ | 13 | "permissions": [ |
14 | - "contextMenus" | 14 | + "contextMenus", |
15 | + "http://localhost:8000/" | ||
15 | ], | 16 | ], |
16 | 17 | ||
17 | "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" | 18 | "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" |