From a0b30e893e3e7296001d51040513aab9d3ac020f Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Fri, 4 Jan 2019 20:14:41 +0000 Subject: [PATCH] initial impl --- package.json | 4 ++-- src/js/background.js | 34 ++++++++++++++++++++++++++++++++++ src/js/popup/example.js | 3 ++- src/manifest.json | 5 ++++- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1ba3435..79748f1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "chrome-extension-webpack", + "name": "grasp-extension", "version": "0.0.1", - "description": "A boilerplate to chrome extension with webpack", + "description": "A reliable way of capturing web pages and content", "scripts": { "build": "node utils/build.js", "start": "node utils/webserver.js" diff --git a/src/js/background.js b/src/js/background.js index 7888299..5dca2eb 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -1,2 +1,36 @@ import '../img/icon-128.png' import '../img/icon-34.png' + +// TODO wtf?? what does that import mean?? + +function makeCaptureRequest() { + var request = new XMLHttpRequest(); + console.log('adadad'); + + // TODO configure port + request.open('POST', 'http://localhost:8000/capture', true); + + + // TODO request header?? + + request.onload = function() { + if (this.status >= 200 && this.status < 400) { + // Success! + var data = JSON.parse(this.response); + console.log(`SUCCESS ${data}`); + } else { + // We reached our target server, but it returned an error + } + }; + + request.onerror = function() { + console.log("ERROR!!!"); + // There was a connection error of some sort + }; + + request.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); + // xmlhttp.send(JSON.stringify({ "email": "hello@user.com", "response": { "name": "Tester" } })); + request.send(JSON.stringify({'name': 'alala', 'age': 10})); +} +makeCaptureRequest(); + diff --git a/src/js/popup/example.js b/src/js/popup/example.js index 6ff89ad..2ee9b52 100644 --- a/src/js/popup/example.js +++ b/src/js/popup/example.js @@ -1,3 +1,4 @@ export default function () { - alert("hello! (find me on src/js/popup/example.js)"); + // alert("hello! (find me on src/js/popup/example.js)"); + }; diff --git a/src/manifest.json b/src/manifest.json index 75bf42f..2735754 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,5 +1,5 @@ { - "name": "Chrome Extension Webpack", + "name": "Grasp Extension", "options_page": "options.html", "background": { "page": "background.html" @@ -8,6 +8,9 @@ "default_popup": "popup.html", "default_icon": "icon-34.png" }, + "permissions": [ + "http://*/" + ], "icons": { "128": "icon-128.png" },