[tor-commits] [snowflake/master] Start a webextension

arlo at torproject.org arlo at torproject.org
Wed May 8 15:41:17 UTC 2019


commit 49dedf3a2f562b4582dcc41d9c82d3f63379d37d
Author: Arlo Breault <arlolra at gmail.com>
Date:   Tue Apr 30 15:08:37 2019 -0400

    Start a webextension
---
 .gitignore                   |   1 +
 proxy/Cakefile               |  12 ++++++++----
 proxy/package.json           |   1 +
 proxy/webext/README.md       |   9 +++++++++
 proxy/webext/icons/16-on.png | Bin 0 -> 1386 bytes
 proxy/webext/icons/16.png    | Bin 0 -> 1119 bytes
 proxy/webext/icons/32-on.png | Bin 0 -> 3035 bytes
 proxy/webext/icons/32.png    | Bin 0 -> 1512 bytes
 proxy/webext/manifest.json   |  16 ++++++++++++++++
 proxy/webext/snowflake.html  |  16 ++++++++++++++++
 proxy/webext/tmp.js          |   2 ++
 11 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 165c512..a187011 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,5 +14,6 @@ proxy/test
 proxy/build
 proxy/node_modules
 proxy/spec/support
+proxy/webext/snowflake.js
 ignore/
 npm-debug.log
diff --git a/proxy/Cakefile b/proxy/Cakefile
index 7da528e..8013dac 100644
--- a/proxy/Cakefile
+++ b/proxy/Cakefile
@@ -21,14 +21,14 @@ FILES_SPEC = [
   'spec/websocket.spec.coffee'
 ]
 FILES_ALL = FILES.concat FILES_SPEC
-OUTFILE = 'build/snowflake.js'
+OUTFILE = 'snowflake.js'
 STATIC = 'static'
 
 copyStaticFiles = ->
   exec 'cp ' + STATIC + '/* build/'
 
-compileCoffee = ->
-  exec 'cat ' + FILES.join(' ') + ' | coffee -cs > ' + OUTFILE, (err, stdout, stderr) ->
+compileCoffee = (outDir) ->
+  exec 'cat ' + FILES.join(' ') + ' | coffee -cs > ' + outDir + '/' + OUTFILE, (err, stdout, stderr) ->
     throw err if err
 
 task 'test', 'snowflake unit tests', ->
@@ -48,9 +48,13 @@ task 'test', 'snowflake unit tests', ->
 task 'build', 'build the snowflake proxy', ->
   exec 'mkdir -p build'
   copyStaticFiles()
-  compileCoffee()
+  compileCoffee('build')
   console.log 'Snowflake prepared.'
 
+task 'webext', 'build the webextension', ->
+  compileCoffee('webext')
+  console.log 'Webextension prepared.'
+
 task 'lint', 'ensure idiomatic coffeescript', ->
   proc = spawn 'coffeelint', FILES_ALL, {
     file: 'coffeelint.json'
diff --git a/proxy/package.json b/proxy/package.json
index cc4cc78..8bc5fb5 100644
--- a/proxy/package.json
+++ b/proxy/package.json
@@ -10,6 +10,7 @@
     "test": "cake test",
     "lint": "cake lint",
     "build": "cake build",
+    "webext": "cake webext",
     "clean": "cake clean",
     "prepublish": "npm run build",
     "start": "node build/snowflake.js"
diff --git a/proxy/webext/README.md b/proxy/webext/README.md
new file mode 100644
index 0000000..bacaa94
--- /dev/null
+++ b/proxy/webext/README.md
@@ -0,0 +1,9 @@
+Build it,
+
+```
+cd ..
+npm install
+npm run webext
+```
+
+and then load this directory as an unpacked extension.
diff --git a/proxy/webext/icons/16-on.png b/proxy/webext/icons/16-on.png
new file mode 100644
index 0000000..5cb253d
Binary files /dev/null and b/proxy/webext/icons/16-on.png differ
diff --git a/proxy/webext/icons/16.png b/proxy/webext/icons/16.png
new file mode 100644
index 0000000..110bae3
Binary files /dev/null and b/proxy/webext/icons/16.png differ
diff --git a/proxy/webext/icons/32-on.png b/proxy/webext/icons/32-on.png
new file mode 100644
index 0000000..fed8ea0
Binary files /dev/null and b/proxy/webext/icons/32-on.png differ
diff --git a/proxy/webext/icons/32.png b/proxy/webext/icons/32.png
new file mode 100644
index 0000000..ee4de34
Binary files /dev/null and b/proxy/webext/icons/32.png differ
diff --git a/proxy/webext/manifest.json b/proxy/webext/manifest.json
new file mode 100644
index 0000000..8d1649e
--- /dev/null
+++ b/proxy/webext/manifest.json
@@ -0,0 +1,16 @@
+{
+	"manifest_version": 2,
+	"name": "Snowflake",
+	"version": "0.0.0",
+	"description": "Snowflake ...",
+	"background": {
+		"page": "snowflake.html",
+		"persistent": true
+	},
+	"browser_action": {
+		"default_icon": {
+			"16": "icons/16.png",
+			"32": "icons/32.png"
+		}
+	}
+}
diff --git a/proxy/webext/snowflake.html b/proxy/webext/snowflake.html
new file mode 100644
index 0000000..6a5eca0
--- /dev/null
+++ b/proxy/webext/snowflake.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<html>
+	<head>
+		<meta charset="utf-8">
+		<!-- FIXME: Use a "script" instead of a "page" in the manifest.json -->
+		<script src="tmp.js"></script>
+		<script src="snowflake.js"></script>
+	</head>
+	<body>
+		<!-- FIXME: Refactor snowflake.js to eliminate the need for this -->
+		<div>
+			<div id="status"></div>
+			<textarea id="msglog" readonly></textarea>
+		</div>
+	</body>
+</html>
diff --git a/proxy/webext/tmp.js b/proxy/webext/tmp.js
new file mode 100644
index 0000000..4bd0a10
--- /dev/null
+++ b/proxy/webext/tmp.js
@@ -0,0 +1,2 @@
+// FIXME: Refactor snowflake.js to eliminate the need for this
+document.cookie = "snowflake-allow=1";





More information about the tor-commits mailing list