forked from andy-portmen/tor-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.js
43 lines (38 loc) · 938 Bytes
/
ui.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* globals EventEmitter */
'use strict';
var ui = new EventEmitter();
ui.cache = {
status: 'disconnected',
ip: '0.0.0.0',
country: '-',
proxy: 'default'
};
ui.on('title', obj => {
ui.cache = Object.assign(ui.cache, obj);
chrome.browserAction.setTitle({
title: `Tor Browser (${ui.cache.status})
IP: ${ui.cache.ip}
Country: ${ui.cache.country}
Proxy: ${ui.cache.proxy}`
});
});
ui.on('title', obj => {
if (obj.status) {
const active = obj.status === 'connected';
chrome.browserAction.setIcon({
path: {
16: '/data/icons/' + (active ? 'enabled/' : '') + '16.png',
32: '/data/icons/' + (active ? 'enabled/' : '') + '32.png',
64: '/data/icons/' + (active ? 'enabled/' : '') + '64.png',
}
});
}
});
ui.notification = function(message) {
chrome.notifications.create({
type: 'basic',
title: 'Tor Control',
message,
iconUrl: '/data/icons/48.png'
});
};