-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlabeler.js
165 lines (127 loc) · 6.2 KB
/
labeler.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
* Privee is released under the BSD 3-Clause License.
* Copyright (c) 2014, Sebastian Zimmeck and Steven M. Bellovin
* All rights reserved.
*
* labeler.js creates the label for the analyzed privacy policy
*
*/
chrome.extension.onMessage.addListener(function(request, sender) {
if (request.action == "forwardClassifications") {
var classifications = request.source;
sessionStorage.setItem("classifications", classifications);
if (classifications == "crowdsourcing") {
crowdsourcingLabel();
}
else {
classificationsLabel(classifications);
}
chrome.extension.sendMessage({
action: "returnLabels"
});
}
});
// create label for crowdsourcing analysis
function crowdsourcingLabel() {
var crowdGrade = sessionStorage.getItem("crowdGrade");
var classes = new Array("good", "bad", "neutral", "blocker");
var crowdClassificationPoints = sessionStorage.getItem("crowdClassificationPoints").split(" ");
var crowdClassificationTitles = sessionStorage.getItem("crowdClassificationTitles").split("~");
var CROWD_CLASSIFICATION_SIZE = sessionStorage.getItem("CROWD_CLASSIFICATION_SIZE");
var crowdLabel = "";
// overall grade according to ToS;DR
if (crowdGrade == "false") {
crowdLabel += '<p><center>   <img src="ToSDRClassNo.jpg"> </center></p>';
}
if (crowdGrade == "A") {
crowdLabel += '<p><center>   <img src="ToSDRClassA.jpg"> </center></p>';
}
if (crowdGrade == "B") {
crowdLabel += '<p><center>   <img src="ToSDRClassB.jpg"> </center></p>';
}
if (crowdGrade == "C") {
crowdLabel += '<p><center>   <img src="ToSDRClassC.jpg"> </center></p>';
}
if (crowdGrade == "D") {
crowdLabel += '<p><center>   <img src="ToSDRClassD.jpg"> </center></p>';
}
if (crowdGrade == "E") {
crowdLabel += '<p><center>   <img src="ToSDRClassE.jpg"> </center></p>';
}
// classifications according to ToS;DR
for (var j=0; j<CROWD_CLASSIFICATION_SIZE; j++) {
if (crowdClassificationPoints[j] == "good") {
crowdLabel += "<p>" + '  <img src="ToSDRgood.jpg" style="float:left">' + " " + '<font size="3">' + crowdClassificationTitles[j] + "</font>" + "</p>";
}
if (crowdClassificationPoints[j] == "bad") {
crowdLabel += "<p>" + '  <img src="ToSDRbad.jpg" style="float:left">' + " " + '<font size="3">' + crowdClassificationTitles[j] + "</font>" + "</p>";
}
if (crowdClassificationPoints[j] == "neutral") {
crowdLabel += "<p>" + '  <img src="ToSDRneutral.jpg" style="float:left">' + " " + '<font size="3">' + crowdClassificationTitles[j] + "</font>" + "</p>";
}
if (crowdClassificationPoints[j] == "blocker") {
crowdLabel += "<p>" + '  <img src="ToSDRblocker.jpg" style="float:left">' + " " + '<font size="3">' + crowdClassificationTitles[j] + "</font>" + "</p>";
}
}
crowdLabel += '<p> Provided by <a href="http://www.tosdr.org/" target="_blank">ToS;DR</a> </p>';
sessionStorage.setItem("crowdLabel", crowdLabel)
}
// create label for automatic analysis
function classificationsLabel(classifications) {
var classes = localStorage.getItem("classes").split(" ");
var CLASSIFICATION_SIZE = localStorage.getItem("CSIZE");
var classesLabels = new Array("Collection of Personal Info (such as e-mail address)", "Combination with Info from outside Companies", "Advertising Tracking (e.g., use of Ad Cookies)", "Disclosure of Personal Info to Advertisers", "Personal Info is only Archived for Limited Time", "Stored and/or Transmitted Info is Encrypted");
var complementClassesLabels = new Array("No Collection of Personal Info (such as e-mail address)", "No Combination with Info from outside Companies", "No Advertising Tracking (e.g., no use of Ad Cookies)", "No Disclosure of Personal Info to Advertisers", "Personal Info is Archived for Unlimited Time", "Stored and Transmitted Info is not Encrypted");
var grade = 0;
// assigning classification labels
for (var j=0; j<CLASSIFICATION_SIZE-2; j++) {
if (classifications[j] == classes[j]) {
sessionStorage.setItem("label"+j, '  <img src="minus.jpg">' + " " + '<font size="3">' + classesLabels[j]) + "</font>";
}
else {
sessionStorage.setItem("label"+j, '  <img src="plus.jpg">' + " " + '<font size="3">' + complementClassesLabels[j]) + "</font>";
}
}
for (var j=CLASSIFICATION_SIZE-2; j<CLASSIFICATION_SIZE; j++) {
if (classifications[j] == classes[j]) {
sessionStorage.setItem("label"+j, '  <img src="plus.jpg">' + " " + '<font size="3">' + classesLabels[j]) + "</font>";
}
else {
sessionStorage.setItem("label"+j, '  <img src="neutral.jpg">' + " " + '<font size="3">' + complementClassesLabels[j]) + "</font>";
}
}
// calculating overall grade and assigning grade label
// for collection, profiling, ad tracking, and ad disclosure minus and plus points are assigned
for (var j=0; j<CLASSIFICATION_SIZE-2; j++) {
if (classifications[j] == classes[j]) {
grade -= 1;
}
else {
grade +=1;
}
}
// for limited retention and encryption only plus points are assigned
for (var j=CLASSIFICATION_SIZE-2; j<CLASSIFICATION_SIZE; j++) {
if (classifications[j] == classes[j]) {
grade += 1;
}
}
// more than 1 point: above average privacy; -1 to 1 points: average privacy; less than -1 point: below average privacy
if (grade > 1) {
sessionStorage.setItem("grade", "A");
}
if (grade <= 1 && grade >= -1) {
sessionStorage.setItem("grade", "B");
}
if (grade < -1) {
sessionStorage.setItem("grade", "C");
}
// assigning headline and explanation labels
sessionStorage.setItem("headline", 'Meaning of Grades and Symbols');
sessionStorage.setItem("explanation1", '<img src="A.jpg"> = Above Average Overall Privacy');
sessionStorage.setItem("explanation2", '<img src="B.jpg"> = Average Overall Privacy');
sessionStorage.setItem("explanation3", '<img src="C.jpg"> = Below Average Overall Privacy');
sessionStorage.setItem("explanation4", '<img src="plus.jpg"> = Good Privacy Practice');
sessionStorage.setItem("explanation5", '<img src="neutral.jpg"> = Neutral Privacy Practice');
sessionStorage.setItem("explanation6", '<img src="minus.jpg"> = Bad Privacy Practice');
}