forked from J2TeamNNL/J2Team-Community
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_photo.html
269 lines (265 loc) · 8.06 KB
/
delete_photo.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
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
<!DOCTYPE html>
<html>
<head>
<title>Delete all photos</title>
<style type="text/css">
.div_hide{
display: none;
}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2-bootstrap-theme/0.1.0-beta.10/select2-bootstrap.css">
</head>
<body>
<div class="container form-horizontal">
<h1>Code xóa toàn bộ ảnh</h1>
<h4>Không xóa được ảnh bìa, ảnh đại diện, ảnh được tag</h4>
<div class="form-group">
<h3>
Nhập token của bạn:
<a href="https://www.facebook.com/groups/j2team.community/search/?query=token" target="_blank">Tìm cách lấy token trong nhóm J2Team Community</a>
</h3>
<input type="text" id="token" class="form-control" placeholder="EAAA...." value="">
<h3>
Chọn đối tượng bạn muốn xoá ảnh
</h3>
<select class="form-control" id="type">
<option value="profile">
Cá nhân Profile
</option>
<option value="page">
Trang Page
</option>
<option value="group">
Nhóm Group
</option>
</select>
</div>
<div class="div_hide div_page form-group">
<h3>
Chọn trang muốn xoá
</h3>
<select id="choose_page">
</select>
</div>
<div class="div_hide div_group form-group">
<h3>
Chọn nhóm muốn xoá
</h3>
<select id="choose_group">
</select>
</div>
<div class="form-group" align="center">
<button class="btn btn-primary">OK</button>
</div>
<div class="form-group div_hide" id="div_result" align="center">
<h1 id="fail">Đang xoá (hãy kiên nhẫn đợi vì chạy từ từ cho chắc)</h1>
<ol id="result" reversed>
</ol>
</div>
</div>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/js/select2.min.js"></script>
<script type="text/javascript">
let token, link, link_album, link_photo, type, id_object, id_album;
var num;
let array_cant_delete = ['cover','wall','mobile','profile','app']
$(document).ready(function(){
$('#choose_group').select2({
theme: "bootstrap"
});
$('#choose_page').select2({
theme: "bootstrap"
});
$("#type").change(function(){
$(".div_group").hide();
$(".div_page").hide();
token = $("#token").val();
type = $("#type").val();
switch(type){
case 'page':
getPage();
break;
case 'group':
getGroup();
break;
}
})
$("button").click(function(e){
e.stopPropagation();
num = 0;
token = $("#token").val();
type = $("#type").val();
$("#div_result").hide();
switch(type){
case 'profile':
link_album = `https://graph.facebook.com/me/albums?fields=id&limit=50&access_token=${token}`;
getAlbum(link_album);
break;
case 'page':
token = $('#choose_page').find(':selected').data('access_token');
id_object = $("#choose_page").val();
link_album = `https://graph.facebook.com/${id_object}/albums?fields=id&limit=50&access_token=${token}`;
getAlbum(link_album);
break;
case 'group':
id_object = $("#choose_group").val();
link_album = `https://graph.facebook.com/${id_object}/albums?fields=id&limit=50&access_token=${token}`;
getAlbum(link_album);
link = `https://graph.facebook.com/${id_object}/feed?fields=full_picture&limit=100&access_token=${token}`;
getFeed(link);
break;
}
});
});
function failToken() {
$("#fail").html('Nhập token sai, hoặc bạn đã bị khoá chức năng');
}
function getPage() {
link = `https://graph.facebook.com/me/accounts?fields=name,access_token&access_token=${token}`;
$.ajax({
url: link,
dataType: 'json'
})
.done(function(response) {
$("#choose_page").html('');
$(response.data).each(function(){
$("#choose_page").prepend(`
<option value='${this.id}' data-access_token='${this.access_token}'>
${this.name}
</option>`);
})
$(".div_page").show();
})
.fail(function() {
failToken();
});
}
function getGroup() {
link = `https://graph.facebook.com/me/groups?fields=name&access_token=${token}`;
$.ajax({
url: link,
dataType: 'json'
})
.done(function(response) {
$("#choose_group").html('');
$(response.data).each(function(){
$("#choose_group").prepend(`<option value='${this.id}'>${this.name}</option>`);
})
$(".div_group").show();
})
.fail(function() {
failToken();
});
}
function getAlbum(link) {
$.ajax({
url: link,
dataType: 'json'
})
.done(function(response) {
$(response.data).each(function(){
var id_album = this.id;
if(array_cant_delete.indexOf(this.type)>0){
num++;
time = Math.random()*5000;
setTimeout(function(){
deleteAjax(id_album);
},
time * num);
console.log(time*num,'album');
}
else{
getPhotoFromAlbum(id_album);
}
})
if(response.paging){
if(response.paging.next){
link = response.paging.next;
getAlbum(link);
}
}
})
.fail(function() {
failToken();
});
}
function getPhotoFromAlbum(id_album) {
link = `https://graph.facebook.com/${id_album}/photos?fields=id&access_token=${token}`;
$.ajax({
url: link,
dataType: 'json'
})
.done(function(response) {
$(response.data).each(function(){
num++;
time = Math.random()*5000;
var id_post = this.id;
setTimeout(function(){
deleteAjax(id_post);
},
time * num);
console.log(time*num,'photo');
})
if(response.paging){
if(response.paging.next){
link = response.paging.next;
getPhotoFromAlbum(id_album);
}
}
})
.fail(function() {
failToken();
});
}
function getFeed(link) {
$.ajax({
url: link,
dataType: 'json'
})
.done(function(response) {
$(response.data).each(function(){
if (typeof this.full_picture !== 'undefined') {
num++;
time = Math.random()*5000;
var id_post = this.id;
setTimeout(function(){
deleteAjax(id_post);
},
time * num);
}
})
if(response.paging){
if(response.paging.next){
link = response.paging.next;
getFeed(link);
}
}
})
.fail(function() {
failToken();
});
}
function deleteAjax(id_post) {
link = `https://graph.facebook.com/${id_post}/?method=delete&access_token=${token}`;
$.ajax({
url: link,
dataType: 'json'
})
.done(function(response) {
if(response=='true'){
$("#div_result").show();
$("#result").append(`<li>Đã xoá ${id_post}</li>`);
}
else{
$("#fail").html('Lỗi');
}
})
.fail(function() {
failToken();
});
}
</script>
</body>
</html>