Permalink
Browse files

new chrome extension, chrome now requires external connections use ss…

…l :(
  • Loading branch information...
1 parent b68e61e commit f4cbb7863a138ba75064d1794e8e77e445d6d723 @quackingduck quackingduck committed Sep 6, 2012
View
@@ -21,21 +21,15 @@ lib/%.js : src/%.coffee
# The filename of the chrome extension
CRX_DIR = browser-extensions/chrome
-CRX_BUILD_DIR = browser-extensions/build
-CRX_SOURCES = $(shell ls $(CRX_DIR)/*)
CRX_VERSION = $(shell cat $(CRX_DIR)/manifest.json | grep version | grep -o [[:digit:]]\.[[:digit:]]\.[[:digit:]])
-CRX_FILE = $(CRX_BUILD_DIR)/reload-browser-v$(CRX_VERSION).crx
+CRX_FILE = reload-browser-v$(CRX_VERSION).zip
# Task to build chrome extension
crx : $(CRX_FILE)
# How chrome extension should be built
$(CRX_FILE) : $(CRX_SOURCES)
- /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
- --pack-extension=$(CRX_DIR) \
- --pack-extension-key=notes/chrome-extension.pem
- mkdir -p $(CRX_BUILD_DIR)
- mv $(CRX_DIR).crx $(CRX_FILE)
+ cd $(CRX_DIR) && zip ../build/$(CRX_FILE) *
# ---
Binary file not shown.
Binary file not shown.
@@ -1,10 +1,12 @@
{ "name": "Reload Browser"
-, "version": "0.4.0"
-, "background_page": "background.html"
+, "version": "1.0.0"
+, "background": { "scripts": [ "reloader.js" ] }
, "permissions":
[ "tabs"
, "http://*/*"
, "https://*/*"
- , "file://*/*"
]
+
+, "manifest_version": 2
+, "content_security_policy": "script-src 'self' https://localhost; object-src 'self'"
}
@@ -1,21 +1,19 @@
-<script>
-
var port = 45729
function connect() {
var lastConnectionAttempt = Date.now()
- var ws = new WebSocket('ws://localhost:' + port)
+ var ws = new WebSocket('wss://localhost:' + port)
ws.onmessage = function(event) {
// todo: do nothing if this "tab" is a dev console?
var msg = JSON.parse(event.data)
- // console.log(msg)
+ console.log(msg)
if (msg.css_only) chrome.tabs.executeScript(null, {file: "reload-css.js"})
else chrome.tabs.reload()
}
- function reconnect() {
+ function reconnect(err) {
if ((Date.now() - lastConnectionAttempt) > 1000) connect()
else setTimeout(connect, 1000)
}
@@ -25,5 +23,3 @@
}
connect()
-
-</script>
View
@@ -0,0 +1,13 @@
+-----BEGIN CERTIFICATE-----
+MIICATCCAWoCCQChIQ9HRlV8tjANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
+VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
+cyBQdHkgTHRkMB4XDTEyMDkwNjIxNTI1M1oXDTEzMDkwNjIxNTI1M1owRTELMAkG
+A1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0
+IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtp0j
+++usUOjLvEMsfP3Zd9QPHjY5GMPqPfRqm6LrdO+Ez8eJIPU72vpMSwe4lAqglVTn
+N5KZ+jUbLKpVt53MYX9KhIaTK9z1N/4y/PyvaRw4eQLC3cU1UIVn53CmN835umhq
+SAUgqS2hzuhViEJGG+FJt253AIvwSndGVgkTB9cCAwEAATANBgkqhkiG9w0BAQUF
+AAOBgQBGHPvYVdvEX21WSX8MeeLE9pMDERviRDIIMnnO1FpypdfE+JiQN2igBpPa
+4o+V0B8TtDm1Rm7uliw5iCg1rVEWunOmKNh2JbjdnZDbrDO3OKlsioanOX3P2kkU
+PaY/idLqPl24mEXazmyxx0WBvXPzi5LgIHF082wxexvIGJPRgw==
+-----END CERTIFICATE-----
View
15 key.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXgIBAAKBgQC2nSP766xQ6Mu8Qyx8/dl31A8eNjkYw+o99Gqbout074TPx4kg
+9Tva+kxLB7iUCqCVVOc3kpn6NRssqlW3ncxhf0qEhpMr3PU3/jL8/K9pHDh5AsLd
+xTVQhWfncKY3zfm6aGpIBSCpLaHO6FWIQkYb4Um3bncAi/BKd0ZWCRMH1wIDAQAB
+AoGAb0Awies74VbRt/HcipFECUKBq1AxXKsOa4wZ3pNUirrY2JShMBj2zCMsk5Ey
+m84VoqRE8JA5ijsMQRvMeL6DoeKb6IIhVsDXBP5ohz183cCVixJh0RCo9YF5u5DQ
+J12FkJwJSwTTuxE7CGnMdFimPbBbCTgz4QJKRgS7fgAopCECQQDdT7yxbbggVEh5
+1juBLtZvZMxI3+k49fjsB2tYHv2wmRE5ajPP31dUmu71kt6CR8kAjIyNPMXb7hl/
+CFyupo4/AkEA0zyi1f5fXyHhFMlCc1U1PrbMQpg1ljLP9bZsNCb/I/nQUvv7PU27
+164COIQRzrLQw7oeQNjP/jmdCqWzT/FQaQJBAMbovsidu6ra9dUDlrHR/gtahj1N
+elmmwhapyHIIUK0jthZrfKvtqZkyM2nmmjRv/pmOuVjL8W1tP98sDdkve5MCQQC4
+9IPDiWmqW3jAAYTMhVQMqHPq72kkLTOHeoX9mBOYRXkR4A5Y3AJYU8UgBQuuh0Vh
+y0oID472ky2dD/8URT/ZAkEAz8yiqhk/5buV5H2OCKgg2NF6xiOIQvAELA/VEkvz
+KSUUyLgVmcpDdSPFX5LvwC/JF2VKcRbPgWUJJ7cJOldAsA==
+-----END RSA PRIVATE KEY-----
View
@@ -1,15 +1,22 @@
(function() {
- var WSServer, connectedWebSockets, http, httpServer, port, qs, wss;
+ var WSServer, connectedWebSockets, fs, httpServer, https, port, qs, sslOptions, wss;
port = 45729;
connectedWebSockets = [];
- http = require('http');
+ https = require('https');
qs = require('querystring');
- httpServer = http.createServer(function(req, res) {
+ fs = require('fs');
+
+ sslOptions = {
+ cert: fs.readFileSync(__dirname + '/../cert.pem'),
+ key: fs.readFileSync(__dirname + '/../key.pem')
+ };
+
+ httpServer = https.createServer(sslOptions, function(req, res) {
var args, s, _i, _len;
args = JSON.stringify(qs.parse(req.url.split("?")[1]));
console.error("reload message received, args: ", args);
View
@@ -70,7 +70,7 @@ then it starts it first then sends it the reload message.
rb.sendReloadMsg = function(args, callback) {
var req;
if (args == null) args = {};
- req = require('http').request({
+ req = require('https').request({
port: this.port,
path: '/?' + require('querystring').stringify(args)
});
View
@@ -6,9 +6,15 @@
port = 45729
connectedWebSockets = []
-http = require 'http'
+https = require 'https'
qs = require 'querystring'
-httpServer = http.createServer (req, res) ->
+fs = require 'fs'
+
+sslOptions =
+ cert: fs.readFileSync __dirname + '/../cert.pem'
+ key: fs.readFileSync __dirname + '/../key.pem'
+
+httpServer = https.createServer sslOptions, (req, res) ->
args = JSON.stringify(qs.parse(req.url.split("?")[1]))
console.error "reload message received, args: ", args
s.send args for s in connectedWebSockets
@@ -47,7 +47,7 @@ rb.reloadBrowser = (args = {}, callback) ->
, 1000
rb.sendReloadMsg = (args = {}, callback) ->
- req = require('http').request
+ req = require('https').request
port: @port
path: '/?' + require('querystring').stringify(args)
req.on 'response', -> callback()

0 comments on commit f4cbb78

Please sign in to comment.