-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
79 lines (68 loc) · 1.84 KB
/
background.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Privee is released under the BSD 3-Clause License.
* Copyright (c) 2014, Sebastian Zimmeck and Steven M. Bellovin
* All rights reserved.
*
* background.js manages the different components of the privacy policy analysis
*/
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {
file: "scraper.js"
}, function() {
});
});
chrome.extension.onMessage.addListener(function(request, sender) {
if (request.action == "returnPrivacyPolicy") {
var privacyPolicy = request.source;
chrome.extension.sendMessage({
//action: "forwardLabels",
action: "getSections",
source: privacyPolicy
});
}
if (request.action == "returnSections") {
chrome.extension.sendMessage({
action: "checkForTraining",
});
}
if (request.action == "trainingRequired") {
chrome.extension.sendMessage({
action: "getTrainingData",
});
}
if (request.action == "returnTrainingData") {
chrome.extension.sendMessage({
action: "train",
});
}
if (request.action == "requestTrainingSections") {
chrome.extension.sendMessage({
action: "getTrainingSections",
});
}
if (request.action == "returnTrainingSections") {
var counter = request.source;
chrome.extension.sendMessage({
action: "forwardTrainingSections",
});
}
if (request.action == "trainingDone") {
chrome.extension.sendMessage({
action: "getClassifications",
});
}
if (request.action == "returnClassifications") {
var classifications = request.source;
chrome.extension.sendMessage({
action: "forwardClassifications",
source: classifications
});
}
if (request.action == "returnLabels") {
var classifications = request.source;
chrome.extension.sendMessage({
action: "forwardLabels",
source: classifications
});
}
});