-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f754849
Showing
29 changed files
with
715 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
var EventEmitter = function () { | ||
this.ecb = {}; | ||
}; | ||
EventEmitter.prototype.emit = function (id, data) { | ||
(this.ecb[id] || []).forEach(c => c(data)); | ||
chrome.runtime.sendMessage({ | ||
cmd: 'event', | ||
id, | ||
data | ||
}); | ||
}; | ||
EventEmitter.prototype.on = function (id, callback) { | ||
this.ecb[id] = this.ecb[id] || []; | ||
this.ecb[id].push(callback); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* globals Tor, proxy, privacy, ui */ | ||
'use strict'; | ||
|
||
var prefs = { | ||
webrtc: 2, | ||
policy: { | ||
'proxy': 0, // 0: turn on when tor is active and turn off when tor is disabled; 1: turn on when browser starts and do not turn off when tor is disabled | ||
'webrtc': 0, // 0: turn on when tor is active and turn off when tor is disabled; 1: turn on when browser starts and do not turn off when tor is disabled | ||
}, | ||
'auto-run': false, | ||
'directory': null | ||
}; | ||
chrome.storage.onChanged.addListener(ps => { | ||
Object.keys(ps).forEach(p => prefs[p] = ps[p].newValue); | ||
}); | ||
|
||
var tor = new Tor({ | ||
directory: '' | ||
}); | ||
|
||
// get external IP address | ||
tor.on('status', status => { | ||
ui.emit('title', {status}); | ||
if (status === 'connected') { | ||
tor.getIP(); | ||
} | ||
}); | ||
|
||
// Set proxy | ||
tor.on('status', s => { | ||
if (s === 'connected') { | ||
proxy.set(tor.info); | ||
privacy.set(prefs.webrtc); | ||
} | ||
else if (s === 'disconnected') { | ||
if (prefs.policy.proxy === 0) { | ||
proxy.reset(); | ||
} | ||
if (prefs.policy.webrtc === 0) { | ||
privacy.reset(); | ||
} | ||
} | ||
}); | ||
// ip changes | ||
tor.on('ip', ip => ui.emit('title', {ip})); | ||
// | ||
proxy.addListener('change', bol => ui.emit('title', { | ||
proxy: bol ? 'SOCKS' : 'default' | ||
})); | ||
chrome.storage.local.get(prefs, p => { | ||
prefs = p; | ||
// directory | ||
tor.directory = p.directory; | ||
// auto run? | ||
if (prefs['auto-run']) { | ||
tor.refresh(); | ||
} | ||
if (prefs.policy.proxy === 1) { | ||
privacy.set(prefs.proxy); | ||
} | ||
if (prefs.policy.webrtc === 1) { | ||
privacy.set(prefs.webrtc); | ||
} | ||
}); | ||
// logs | ||
proxy.addListener('change', s => { | ||
tor.emit('stdout', `Proxy status is "${s}"`); | ||
}); | ||
privacy.addListener('change', (type, state) => { | ||
tor.emit('stdout', `Protection: module -> ${type}, status -> ${state}`); | ||
}); | ||
|
||
chrome.runtime.onMessage.addListener(request => { | ||
if (request.method === 'popup-command') { | ||
if (request.cmd) { | ||
tor.command(request.cmd); | ||
} | ||
} | ||
else if (request.method === 'popup-action') { | ||
if (request.cmd === 'connection') { | ||
if (request.action === 'disconnect') { | ||
tor.disconnect(); | ||
} | ||
else { | ||
if (prefs.directory) { | ||
tor.refresh(); | ||
} | ||
else { | ||
ui.notification('Tor Bundle path is not set in the options page'); | ||
chrome.runtime.openOptionsPage(); | ||
} | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../external-application-button/data/helper/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>My Test Extension Options</title> | ||
<style> | ||
body { | ||
padding: 10px; | ||
} | ||
input[type=text] { | ||
width: 100%; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<p> | ||
Tor bundle path: | ||
<input type="text" id="directory" placeholder="e.g.: C:\Users\username\Desktop\tor"> | ||
<div>First download the latest "Tor Bundle" pack from <a href="">github.com</a>, and extract it in a local directory. Then place the root's absolute path here.</div> | ||
</p> | ||
|
||
<div> | ||
<button id="save">Save</button> | ||
<span id="status"></span> | ||
</div> | ||
|
||
<script src="index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
function save () { | ||
let directory = document.getElementById('directory').value; | ||
chrome.storage.local.set({ | ||
directory | ||
}, () => { | ||
let status = document.getElementById('status'); | ||
status.textContent = 'Options saved.'; | ||
setTimeout(() => status.textContent = '', 750); | ||
}); | ||
} | ||
|
||
function restore () { | ||
chrome.storage.local.get({ | ||
directory: '', | ||
}, (prefs) => { | ||
document.getElementById('directory').value = prefs.directory; | ||
}); | ||
} | ||
document.addEventListener('DOMContentLoaded', restore); | ||
document.getElementById('save').addEventListener('click', save); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
body { | ||
width: 500px; | ||
height: 300px; | ||
} | ||
img { | ||
cursor: pointer; | ||
} | ||
input[type=button] { | ||
border: solid 1px #eee; | ||
background-color: #fff; | ||
width: 120px; | ||
margin: 2px 0; | ||
outline: none; | ||
cursor: pointer; | ||
} | ||
input { | ||
outline: none; | ||
} | ||
input[type=button]:active { | ||
border-color: #00a; | ||
} | ||
|
||
[hbox] { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
[vbox] { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
[flex="1"] { | ||
flex: 1; | ||
} | ||
[flex="2"] { | ||
flex: 2; | ||
} | ||
[pack=center] { | ||
justify-content: center; | ||
} | ||
[align=center] { | ||
align-items: center; | ||
} | ||
body[data-status=connecting] img[data-cmd=connection] { | ||
opacity: 0.3; | ||
} | ||
|
||
#log { | ||
padding: 10px; | ||
overflow-x: hidden; | ||
overflow-y: auto; | ||
width: calc(47vw - 20px); | ||
background-color: rgba(0, 0, 0, 0.01); | ||
border: dashed 1px rgba(0, 0, 0, 0.05); | ||
} | ||
#log>* { | ||
margin-bottom: 10px; | ||
} | ||
#toolbar { | ||
margin-top: 8px; | ||
} | ||
|
||
.msg span:nth-child(1) { | ||
font-size: 80%; | ||
} | ||
.msg span:nth-child(2) { | ||
padding: 0 5px; | ||
background-color: rgba(0, 0, 0, 0.05); | ||
} | ||
|
||
.log { | ||
background-color: rgba(0, 0, 0, 0.05); | ||
border: dotted 1px rgba(0, 0, 0, 0.05); | ||
padding: 0 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | ||
<link rel="stylesheet" href="index.css"> | ||
</head> | ||
<body vbox> | ||
<div hbox flex=1> | ||
<div flex=1 hbox id="toggle" pack="center" align="center"> | ||
<img width="120" height="120" src="off.png" data-cmd="connection"> | ||
</div> | ||
|
||
<div flex=2 vbox id="log"> | ||
<template> | ||
<div class="msg"> | ||
<span></span> | ||
<span></span> | ||
<span></span> | ||
</div> | ||
</template> | ||
</div> | ||
</div> | ||
<div id="toolbar"> | ||
<input type="button" value="New Identity" data-rcmd="SIGNAL NEWNYM"> | ||
<input type="button" value="Get IP" data-rcmd="GETINFO address"> | ||
<input type="button" value="Status" data-rcmd="GETINFO circuit-status"> | ||
<input type="button" value="Verify" data-cmd="verify"> | ||
</div> | ||
|
||
<script src="index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
'use strict'; | ||
|
||
var elements = { | ||
log: document.getElementById('log'), | ||
template: document.querySelector('#log template'), | ||
webrtc: document.getElementById('prefs.webrtc') | ||
}; | ||
|
||
function log (msg) { | ||
function single (msg) { | ||
let node = document.importNode(elements.template.content, true); | ||
let parts = /(.*)\[(err|warn|notice)\] (.*)/.exec(msg); | ||
if (parts) { | ||
node.querySelector('span:nth-child(1)').textContent = parts[1]; | ||
node.querySelector('span:nth-child(2)').textContent = parts[2]; | ||
node.querySelector('span:nth-child(3)').textContent = parts[3]; | ||
} | ||
else { | ||
node = document.createElement('span'); | ||
node.classList.add('log'); | ||
node.textContent = msg; | ||
} | ||
|
||
elements.log.appendChild(node); | ||
elements.log.scrollTop = elements.log.scrollHeight; | ||
} | ||
msg.split('\n').filter(m => m.trim()).forEach(single); | ||
} | ||
|
||
function status (s) { | ||
document.body.dataset.status = s; | ||
document.querySelector('[data-cmd="connection"]').src = | ||
s === 'disconnected' ? 'off.png' : 'on.png'; | ||
} | ||
|
||
window.addEventListener('load', () => { | ||
chrome.runtime.getBackgroundPage(b => { | ||
log(b.tor.info.stdout); | ||
status(b.tor.info.status); | ||
}); | ||
}); | ||
|
||
chrome.runtime.onMessage.addListener(request => { | ||
if (request.cmd === 'event' && request.id === 'stdout') { | ||
log(request.data); | ||
} | ||
else if (request.cmd === 'event' && request.id === 'status') { | ||
status(request.data); | ||
} | ||
}); | ||
|
||
document.addEventListener('click', e => { | ||
let cmd = e.target.dataset.rcmd; | ||
if (cmd) { | ||
chrome.runtime.sendMessage({ | ||
method: 'popup-command', | ||
cmd | ||
}); | ||
} | ||
cmd = e.target.dataset.cmd; | ||
if (cmd === 'verify') { | ||
chrome.tabs.create({ | ||
url: 'https://check.torproject.org/' | ||
}); | ||
} | ||
else if (cmd === 'connection') { | ||
chrome.runtime.sendMessage({ | ||
method: 'popup-action', | ||
cmd, | ||
action: document.body.dataset.status === 'disconnected' ? 'connect' : 'disconnect' | ||
}); | ||
} | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "Tor Browser", | ||
"short_name": "itbrowser", | ||
"description": "Enables Tor network and modify few settings to protect user privacy", | ||
"author": "Jeremy Schomery", | ||
"version": "0.1.0", | ||
"manifest_version": 2, | ||
"permissions": [ | ||
"storage", | ||
"tabs", | ||
"proxy", | ||
"privacy", | ||
"webRequest", | ||
"downloads", | ||
"management", | ||
"notifications", | ||
"nativeMessaging", | ||
"https://api.github.com/repos/andy-portmen/native-client/releases/latest" | ||
], | ||
"background": { | ||
"scripts": [ | ||
"EventEmitter.js", | ||
"tor.js", | ||
"proxy.js", | ||
"privacy.js", | ||
"ui.js", | ||
"common.js" | ||
] | ||
}, | ||
"browser_action": { | ||
"default_icon": { | ||
"16": "data/icons/16.png", | ||
"32": "data/icons/32.png" | ||
}, | ||
"default_popup": "data/popup/index.html" | ||
}, | ||
"homepage_url": "http://add0n.com/media-tools.html", | ||
"icons": { | ||
"16": "data/icons/16.png", | ||
"48": "data/icons/48.png", | ||
"128": "data/icons/128.png" | ||
}, | ||
"options_ui": { | ||
"page": "data/options/index.html", | ||
"chrome_style": true | ||
} | ||
} |
Oops, something went wrong.