-
Notifications
You must be signed in to change notification settings - Fork 0
/
new 2.txt
executable file
·151 lines (124 loc) · 5.17 KB
/
new 2.txt
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
settings = {}; // settings array
settingLabel = "";
settingValue = "";
userID = "100000037056271";
var req = new XMLHttpRequest();
// "how you connect" settings
req.open(
"GET",
"https://www.facebook.com/ajax/settings/privacy/connect.php?__a=1&__d=1&__user=" + userID,
true
);
req.onload = show1;
req.send(null);
function show1() {
response = req.responseText;
// 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");
//temp = settingLabel;alert(temp);
}
var req2 = new XMLHttpRequest();
// "timeline and tagging" settings
req2.open(
"GET",
"https://www.facebook.com/ajax/settings/privacy/tag.php?__a=1&__d=1&__user=" + userID,
true
);
req2.onload = show2;
req2.send(null);
function show2() {
response = req2.responseText;
// 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");
}
var req3 = new XMLHttpRequest();
// "Work and Education" settings
req3.open(
"GET",
"https://www.facebook.com/ajax/timeline/edit_profile/eduwork.php?__a=1&__user=" + userID,
true
);
req3.onload = show3;
req3.send(null);
function show3() {
response = req3.responseText;
// 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");
show_sett(settings);
}
function show_sett(set)
{
var res;
$.each(set, function() {
res += set;
});
alert(res);
}
function save_sett() {
// 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!")
});
}