-
Notifications
You must be signed in to change notification settings - Fork 3
/
site.html
executable file
·202 lines (192 loc) · 8.71 KB
/
site.html
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
---
layout: default_site
isSite: true
title: Data Transparency Lab
---
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://d3js.org/topojson.v2.min.js"></script>
</head>
<body>
<div id="site-header">Site Checker</div>
<div class="clearfix"> </div>
<div id="report-wrapper" style="display: none;">
<div class="row" style="font-size: 24px; color:#8D2E94; ">
<div class="col-md-6">
<p id="report-site" style="text-align:left; text-indent: 3em;">Report for N/A</p>
<!-- <p><a class="btn btn-default" href="#" role="button">View details »</a></p> -->
</div>
<div class="col-md-6">
<p id="updated" class="pull-right" style="vertical-align:baseline ; font-size:18px; color:#9B9B9B; padding-right: 50px;">
Last updated: <span id="last-update"> - </span> </p>
</div>
</div>
<div class="site-check-box">
<h2>Overview</h2>
<div style="text-indent: 20px;">
<p>Country: <span id="report-country"> - </span></p>
<p> Kind of website: <span id="report-category"> - </span></p>
</div>
</div>
<div id="siteReport" style="display:none">
<h3>Does this site fingerprint? <span id="boolFingerprint"><i class="fa fa-exclamation-triangle fa-1x "></i> - </span></h3>
</div>
<div id="kindsFP" class="site-check-box-sub" style="display:none">
<p>The following fingerprinting scripts are being deployed:</p>
<ul>
<li id="fpTypeList"></li>
</ul>
<div class="report-box-divider"></div>
</div>
</div>
<div id="addInfo" style="display:none">
<div class="site-check-box-sub">
<h2>Additional Info.</h2>
<h3>How many (monthly) visits were fingerprinted?</h3>
<div>
<div id="report-traffic" class="number-highlight"> - </div>
</div>
</div>
<div class="site-check-box-sub">
<h3>Where are fingerprinted visitors located (highest ranking countries)?</h3>
<div id="trafficMap"> </div>
</div>
<div class="site-check-box-sub">
<h3>What are visitors also interested in?</h3>
<div id="categoriesAudience">
<ul>
<li id="audience"></li>
</ul>
</div>
</div>
</div>
<div id="notFound" style="display:none">
<h2><i class="fa fa-exclamation-circle fa-4x" style="color:#DF564D;"></i></h2>
<h3>Looks like we've got homework!</h3>
<h4>Sorry, we haven't scanned <span id="report-site-not-found"> - </span> yet. We have added it to our to-do list, please
come back in one month and search for it again. Thank you! </h4>
</div>
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>
<script src="script/d3.min.js"></script>
<script src="script/privacymeter-single-report.js"></script>
<script>
var mydata = "test";
var url = getParameters();
var encUrl = "";
if (!validUrl(url)) {
//console.log("Url no valida: " + url);
} else {
//console.log("Valid url: " + url);
encUrl = urlEncoder(url);
$('#data11').val(encUrl);
};
var myquerydb = querydb(encUrl);
function querydb(a) {
//console.log("Valid url: " + a);
return $.getJSON('https://privacymeter-dtl.firebaseio.com/sites/' + a + '.json', function (data) {
updateContent(data);
if (data != null && data.hasOwnProperty("fingerprint")) {
top_trackers = data.information.traffic_top;
draw(topo); //updateContent(data);
}
//console.log("query sent");
});
}
function getLastUpdate() {
//console.log("Valid url: " + a);
return $.getJSON('https://privacymeter-dtl.firebaseio.com/insights/last_update.json', function (data) {
$("#last-update").html(data)
});
}
function validUrl(str) {
var expression = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi;
var pattern = new RegExp(expression);
if (!pattern.test(str)) {
alert("Please enter a valid URL.");
return false;
} else {
return true;
}
}
function urlEncoder(url) {
var result = '';
for (i = 0; i < url.length; i++) {
result += url.charCodeAt(i).toString(16);
}
//console.log("Encoded url: " + result);
return result;
}
function getParameters() {
return location.search.split('?')[1]
}
function updateContent(siteData) {
//console.log("checking if loop"); //fucntion to update the content using the json
getLastUpdate()
if (siteData == null) {
$("#report-site-not-found").html(url)
$("#notFound").show();
var newQueryRef = new Firebase('https://privacymeter-dtl.firebaseio.com/queries');
newQueryRef.push({
"url": url
});
//console.log("NOT IN OUR DB!");
} else {
$("#report-site").html("Report for " + siteData.url)
$("#report-country").html(siteData.information.country)
$("#report-category").html(siteData.information.category)
$("#report-wrapper").show();
//console.log("Is tracking?")
if (siteData.hasOwnProperty("fingerprint")) {
//console.log("YES")
$("#boolFingerprint").html("YES")
$("#siteReport").show();
$("#kindsFP").show();
$("#addInfo").show();
fingerprints = siteData["fingerprint"]["201612"]
//console.log("The following fingerprinting scripts are being deployed:")
var list = ""
for (var key in fingerprints) {
//console.log(key)
$("#fpTypeList").append("<li>" + key.capitalizeFirstLetter() + " fingerprinting: <ul><li id=" +
key + "></li></ul></li>");
if (fingerprints.hasOwnProperty(key)) {
scriptfArray = fingerprints[key]
////console.log(key + " -> " + fingerprints[key]);
scriptfArray.forEach(function (script) {
$("#" + key).append(script)
//console.log(script);
});
}
}
} else {
//console.log("NO")
$("#boolFingerprint").html("NO")
$("#siteReport").show();
}
//console.log("How many (monthly) visits were fingerprinted?")
//console.log(siteData["information"]["traffic"])
$("#report-traffic").html(parseInt(siteData["information"]["traffic"]).toLocaleString())
//console.log("Where are fingerprinted visitors located?")
//MAP
top_traffic = siteData["information"]["traffic_top"]
var arrayTopTraffic = [];
for (country in top_traffic) {
arrayTopTraffic.push([country, top_traffic[country]])
}
arrayTopTraffic.sort(function (a, b) {
return a[1] - b[1]
})
arrayTopTraffic.reverse();
window.arrayTopTraffic = arrayTopTraffic;
//console.log(arrayTopTraffic);
//console.log("What are visitors also interested in?");
audienceArray = siteData.information.audience;
audienceArray.forEach(function (audienceType) {
//console.log("my_audience", audienceType);
$("#audience").append("<li>" + audienceType + "</li>");
});
}
}
String.prototype.capitalizeFirstLetter = function () {
return this.charAt(0).toUpperCase() + this.slice(1);
}
</script>