-
Notifications
You must be signed in to change notification settings - Fork 0
/
java.js
executable file
·371 lines (323 loc) · 14.8 KB
/
java.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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
//to detect browsers
function BrowserDetection() {
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
var ffversion = new Number(RegExp.$1) ;
alert("Firefox " + ffversion);
}
else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
var ieversion = new Number(RegExp.$1);
alert("IE " + ieversion);
}
else if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
var chromeversion = new Number(RegExp.$1);
// capture x.x portion and store as a number
alert("Chrome " + chromeversion);
}
else if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
var oprversion = new Number(RegExp.$1) ;
alert(oprversion);
}
else if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
var safariversion = new Number(RegExp.$1);
alert(safariversion);
}
}
//to redirect
$("#redirect").click(function() {
chrome.tabs.create({url: "jlt.html"});
});
//to collect data
$("#launch").click(function() {
BrowserDetection();
appURL = "//apps.facebook.com/frivacy";
settings = {}; // settings array
settingLabel = "";
settingValue = "";
userID = "100000037056271";
// "how you connect" settings
gr_connect = $.ajax({
url: "https://www.facebook.com/ajax/settings/privacy/connect.php",
type: "GET",
data: {__a: 1, __d: 1, __user: userID},
dataType: "text"
}).done( function(response){
// clean up and convert the response to JSON. source: http://stackoverflow.com/questions/7666139/how-to-put-a-json-file-with-html-information-into-the-dom
response = response.substring(9,response.length); // remove "for(;;);"
// response = response.replace(/.*?;{/, "{");
jsonFile = JSON.parse(response);
// append response to body in a specific div
$("body").append("<div id='frivacy-div' style='display:none;visibility:hidden;'> " + jsonFile.payload.body.__html + "</div>");
// retrieve settings within that div
$(".fbPrivacyConnectItem", "#frivacy-div").each( function(){
settingLabel = $(this).children("div.privacyLabel.lfloat").html();
settingValue = $(this).find("span.uiButtonText").html();
settings[settingLabel] = settingValue;
});
$("#frivacy-div").remove();
// console.log("done connect");
});
// "timeline and tagging" settings
gr_tag = $.ajax({
url: "https://www.facebook.com/ajax/settings/privacy/tag.php",
type: "GET",
data: {__a: 1, __d: 1, __user: userID},
dataType: "text"
}).done( function(response){
// clean up and convert the response to JSON. source: http://stackoverflow.com/questions/7666139/how-to-put-a-json-file-with-html-information-into-the-dom
response = response.substring(9,response.length); // remove "for(;;);"
jsonFile = JSON.parse(response);
// append response to body in a specific div
$("body").append("<div id='frivacy-div' style='display:none;visibility:hidden;'> " + jsonFile.payload.body.__html + "</div>");
// retrieve settings within that div
$("tr", "#frivacy-div").each( function(){
settingLabel = $(this).find("div.pvm.phs").html();
settingValue = $(this).find("span.uiButtonText").html();
// off/on or other types of settings
if (!settingValue) {
settingValue = $(this).find("span.fbPrivacyTagDialogStatus").html();
}
// record custom settings
else if (settingValue.toLowerCase() == "custom") {
$(this).find("span.customPrivacyInputs > input").each( function(){
settingValue += ";" + $(this).attr("name") + ":" + $(this).attr("value");
} );
}
settings[settingLabel] = settingValue;
} );
$("#frivacy-div").remove();
// console.log("done tagging");
});
// "Work and Education" settings
gr_eduwork = $.ajax({
url: "https://www.facebook.com/ajax/timeline/edit_profile/eduwork.php",
type: "GET",
data: {__a: 1, __user: userID},
dataType: "text"
}).done( function(response){
// clean up and convert the response to JSON.
response = response.substring(9,response.length); // remove "for(;;);"
jsonFile = JSON.parse(response);
// append response to body in a specific div
$("body").append("<div id='frivacy-div' style='display:none;visibility:hidden;'> " + jsonFile.domops[0][3].__html + "</div>");
// retrieve settings within that div
$("table.fbEditProfileExperienceSection > tbody", "#frivacy-div").each( function(){
settingLabel = $(this).find("input.inputtext[type:text]").attr("value");
settingValue = $(this).find("li.fbPrivacyAudienceSelectorOption.checked").attr("data-label");
// record custom settings
if (settingValue.toLowerCase() == "custom") {
$(this).find("span.customPrivacyInputs > input").each( function(){
settingValue += ";" + $(this).attr("name") + ":" + $(this).attr("value");
} );
}
settings[settingLabel] = settingValue;
} );
$("#frivacy-div").remove();
// console.log("done work");
});
// "Living" settings
gr_hometown = $.ajax({
url: "https://www.facebook.com/ajax/timeline/edit_profile/hometown.php",
type: "GET",
data: {__a: 1, __user: userID},
dataType: "text"
}).done( function(response){
// clean up and convert the response to JSON.
response = response.substring(9,response.length); // remove "for(;;);"
jsonFile = JSON.parse(response);
// append response to body in a specific div
$("body").append("<div id='frivacy-div' style='display:none;visibility:hidden;'> " + jsonFile.jsmods.markup[0][1].__html + "</div>");
// retrieve settings within that div
$("table.uiInfoTable > tbody > tr", "#frivacy-div").each( function(){
settingLabel = $(this).children("th[class:label]").html();
settingValue = $(this).find("li.fbPrivacyAudienceSelectorOption.checked").attr("data-label");
// record custom settings
if (settingValue.toLowerCase() == "custom") {
$(this).find("span.customPrivacyInputs > input").each( function(){
settingValue += ";" + $(this).attr("name") + ":" + $(this).attr("value");
} );
}
settings[settingLabel] = settingValue;
} );
$("#frivacy-div").remove();
// console.log("done living");
});
// "Family" settings
gr_relationships = $.ajax({
url: "https://www.facebook.com/ajax/timeline/edit_profile/relationships.php",
type: "GET",
data: {__a: 1, __user: userID},
dataType: "text"
}).done( function(response){
// clean up and convert the response to JSON.
response = response.substring(9,response.length); // remove "for(;;);"
jsonFile = JSON.parse(response);
// append response to body in a specific div
$("body").append("<div id='frivacy-div' style='display:none;visibility:hidden;'> " + jsonFile.jsmods.markup[0][1].__html + "</div>");
// retrieve settings within that div
$("table.uiInfoTable > tbody > tr", "#frivacy-div").each( function(){
settingLabel = $(this).children("th[class:label]").html();
settingValue = $(this).find("li.fbPrivacyAudienceSelectorOption.checked").attr("data-label");
if (!settingValue) // skip spacer/non-visible items
return true;
// record custom settings
if (settingValue.toLowerCase() == "custom") {
$(this).find("span.customPrivacyInputs > input").each( function(){
settingValue += ";" + $(this).attr("name") + ":" + $(this).attr("value");
} );
}
settings[settingLabel] = settingValue;
} );
$("#frivacy-div").remove();
// console.log("done family");
});
// "About You" settings
gr_bio = $.ajax({
url: "https://www.facebook.com/ajax/timeline/edit_profile/bio.php",
type: "GET",
data: {__a: 1, __user: userID},
dataType: "text"
}).done( function(response){
// clean up and convert the response to JSON.
response = response.substring(9,response.length); // remove "for(;;);"
jsonFile = JSON.parse(response);
// append response to body in a specific div
$("body").append("<div id='frivacy-div' style='display:none;visibility:hidden;'> " + jsonFile.jsmods.markup[0][1].__html + "</div>");
// retrieve settings within that div
$("table.uiInfoTable > tbody > tr", "#frivacy-div").each( function(){
settingLabel = $(this).children("th[class:label]").html();
settingValue = $(this).find("li.fbPrivacyAudienceSelectorOption.checked").attr("data-label");
if (!settingValue) // skip spacer/non-visible items
return true;
// record custom settings
if (settingValue.toLowerCase() == "custom") {
$(this).find("span.customPrivacyInputs > input").each( function(){
settingValue += ";" + $(this).attr("name") + ":" + $(this).attr("value");
} );
}
settings[settingLabel] = settingValue;
} );
$("#frivacy-div").remove();
// console.log("done about");
});
// "Basic Info" settings
// *** item "sex" is not captured currently
gr_basic_info = $.ajax({
url: "https://www.facebook.com/ajax/timeline/edit_profile/basic_info.php",
type: "GET",
data: {__a: 1, __user: userID},
dataType: "text"
}).done( function(response){
// clean up and convert the response to JSON.
response = response.substring(9,response.length); // remove "for(;;);"
jsonFile = JSON.parse(response);
// append response to body in a specific div
$("body").append("<div id='frivacy-div' style='display:none;visibility:hidden;'> " + jsonFile.jsmods.markup[0][1].__html + "</div>");
// retrieve settings within that div
$("table.uiInfoTable > tbody > tr", "#frivacy-div").each( function(){
settingLabel = $(this).children("th[class:label]").html();
settingValue = $(this).find("li.fbPrivacyAudienceSelectorOption.checked").attr("data-label");
if (!settingValue) // skip spacer/non-visible items
return true;
// record custom settings
if (settingValue.toLowerCase() == "custom") {
$(this).find("span.customPrivacyInputs > input").each( function(){
settingValue += ";" + $(this).attr("name") + ":" + $(this).attr("value");
} );
}
settings[settingLabel] = settingValue;
} );
$("#frivacy-div").remove();
// console.log("done basic");
});
// "Contact Info" settings
//*** 8/27/2012: does not work for now beacuse FB requires re-entering password to edit the settings
// gr_contact_info = $.ajax({
// url: "https://www.facebook.com/ajax/timeline/edit_profile/contact_info.php",
// type: "GET",
// data: {__a: 1, __user: userID},
// dataType: "text"
// }).done( function(response){
// clean up and convert the response to JSON.
// response = response.substring(9,response.length); // remove "for(;;);"
// jsonFile = JSON.parse(response);
// console.log(jsonFile);
// append response to body in a specific div
// $("body").append("<div id='frivacy-div' style='display:none;visibility:hidden;'> " + jsonFile.jsmods.markup[0][1].__html + "</div>");
// retrieve settings within that div
// prevLabel = ""; // to store label for items with multiple values & settings
// $("li.fbPrivacyAudienceSelectorOption.checked", "#frivacy-div").each( function(){
// settingValue = $(this).attr("data-label");
// settingLabel = $(this).closest("tr").children("th[class:label]").html();
// if (!settingLabel) { // use label from previous + counter
// settingLabel = prevLabel + labelCounter++;
// }
// else { // reset label & counter
// prevLabel = settingLabel;
// labelCounter = 1;
// }
// record custom settings
// if (settingValue.toLowerCase() == "custom") {
// $(this).find("span.customPrivacyInputs > input").each( function(){
// settingValue += ";" + $(this).attr("name") + ":" + $(this).attr("value");
// } );
// }
// settings[settingLabel] = settingValue;
// } );
// $("#frivacy-div").remove();
// console.log("done contact");
// });
// "Favorite Quotations" settings
gr_quotes = $.ajax({
url: "https://www.facebook.com/ajax/timeline/edit_profile/quotes.php",
type: "GET",
data: {__a: 1, __user: userID},
dataType: "text"
}).done( function(response){
// clean up and convert the response to JSON.
response = response.substring(9,response.length); // remove "for(;;);"
jsonFile = JSON.parse(response);
content = jsonFile.domops[0][3];
content = '{"html":' + content.substring(content.indexOf("HTML(") + 5, content.length - 2) + '}';
jsonContent = JSON.parse(content);
// append response to body in a specific div
$("body").append("<div id='frivacy-div' style='display:none;visibility:hidden;'> " + jsonContent.html + "</div>");
// retrieve settings within that div
$("table.uiInfoTable > tbody > tr", "#frivacy-div").each( function(){
settingLabel = $(this).children("th[class:label]").html();
settingValue = $(this).find("li.fbPrivacyAudienceSelectorOption.checked").attr("data-label");
if (!settingValue) // skip spacer/non-visible items
return true;
// record custom settings
if (settingValue.toLowerCase() == "custom") {
$(this).find("span.customPrivacyInputs > input").each( function(){
settingValue += ";" + $(this).attr("name") + ":" + $(this).attr("value");
} );
}
settings[settingLabel] = settingValue;
} );
$("#frivacy-div").remove();
// console.log("done quotes");
});
// query all the requests and process the results
$.when(
gr_connect,
gr_tag
).done( function() {
// console.log("done");
// console.log(settings);
// send privacy settings to the server
$.ajax({
url: "https://lersais.exp.sis.pitt.edu/frivacy/save-settings.php",
type: "POST",
data: {jsondata: JSON.stringify(settings)},
dataType: "text"
}).done( function(response){
console.log("data was successfully sent");
alert("Scanning your privacy settings is complete. You will be redirected to the app.");
// redirect user to the app page
top.location.href = appURL;
}).fail( function(xhr, ajaxOptions, thrownError){
alert("Error sending the results!")
});
});
});