-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (51 loc) · 1.81 KB
/
index.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
44
45
46
47
48
49
50
51
52
53
54
55
56
var self = require('sdk/self');
var panel = require("sdk/panel");
var pageMod = require('sdk/page-mod');
var RndPhrase = require("rndphrase");
var seed = undefined;
var dataUrl = self.data.url;
//This is the stuff dreams are made of. Or at least just RndPhrase
pageMod.PageMod({
include: "*",
contentScriptFile: dataUrl("eventhandler.js"),
contentScriptWhen: "ready",
onAttach: function(worker) {
// Ensure the seed has been set
if(undefined === seed){
var seedPanel = panel.Panel({
height: 60,
width: 300,
contentURL: dataUrl("prompt-seed.html"),
contentScriptFile: [dataUrl('prompt-seed.js')]
});
seedPanel.show();
seedPanel.port.emit('show');
seedPanel.port.on('seed-changed', function(new_seed) {
seed = new_seed; //needs to go through a hash
seedPanel.hide();
});
}
// Setup port event-handling
worker.port.on("generate", function(message) {
var domain = message.domain;
var passwordPanel = panel.Panel({
height: 60,
contentURL: dataUrl("prompt-password.html"),
contentScriptFile: [dataUrl('prompt-password.js')]
});
passwordPanel.port.on('password-changed', function(message) {
var r = new RndPhrase({
'seed': seed,
'uri': domain
});
hash = r.generate(message.password);
worker.port.emit('hash', {
'hash': hash
});
passwordPanel.hide();
});
passwordPanel.show();
passwordPanel.port.emit('show');
});
}
});