-
Notifications
You must be signed in to change notification settings - Fork 0
/
contentScript.js
135 lines (126 loc) · 4.75 KB
/
contentScript.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
function KickMember(idgroup, idUser, fb_dtsg) {
var Optional = {
method: "POST",
credentials: "include",
mode: 'cors',
headers: {
'Access-Control-Allow-Origin': '*'
},
headers: {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
},
body: 'fb_dtsg=' + fb_dtsg + '&confirm=true&ban_user=1&jazoest=1'
};
var check = fetch(
"https://www.facebook.com/ajax/groups/members/remove.php?group_id=" + idgroup + "&user_id=" + idUser + "&is_undo=0&source=profile_browser&dpr=1", Optional)
.then(function (res) {
if (res) {
//remove element
//all_members_100024665686564 at member page
if ($('#all_members_' + idUser).length > 0) {
$('#all_members_' + idUser).hide();
}
}
return res ? true : false
});
return check;
}
var fb_dtsg = document.querySelector('[name="fb_dtsg"]').value;
chrome.runtime.onMessage.addListener(
function (req, sender, sendResponse) {
if (req.action == 'ban') {
var check = KickMember(req.groupId, req.userId, fb_dtsg);
sendResponse(check ? 1 : 0);
if (!check) {
alert('Kick member failed!')
} else {
//increase death
chrome.storage.sync.get("numBan", function (data) {
var numBan = data.numBan;
if (numBan == undefined || numBan == null) {
numBan = 1;
} else {
numBan++;
}
chrome.storage.sync.set({numBan: numBan}, function () {
console.log("Increased banned user");
});
chrome.runtime.sendMessage({action: 'badgetText'});
});
}
}
return true;
});
//Request URL: https://www.facebook.com/ajax/groups/members/remove.php?group_id=794125374111799&user_id=100025669965969&is_undo=0&source=profile_browser&dpr=2
/*
fb_dtsg: AQEwCuU3Ap7I:AQGLm5Mb9fBS
confirm: true
ban_user: 1
__user: 100000045292063
__a: 1
__dyn: 7AgNe-4amaxx2u6aJGeFxqewRyWzEy4aheC267Uqzob4q2i5U4e2C3-7WUC6UnG2OUG4XzEeWDgdUHzobohx3wDxrDx2UO5UlwQxS58iwBx61zwzwnqxW5o7Cum2S2G262i6rGUpxy5UrwFwgEdoK7Uy5UGdUC2C2GdzE_Wx28wn8OER7x3x69wyQF8my9m4S5oSmiaz9oCmUpzUiVE4W10Gu15h8J2EgUWV8zwEwFypUKU42
__req: 22
__be: 1
__pc: PHASED:DEFAULT
__rev: 4143791
jazoest: 26581691196711785516511255735865817176109537798571026683
__spin_r: 4143791
__spin_b: trunk
__spin_t: 1532613540*/
//Ban In Pending page
$(function () {
banAllPedningWrong();
});
function banAllPedningWrong() {
if ($('#pagelet_pending_queue .userContentWrapper').length > 0) {
var banNum = 0;
//#pagelet_pending_queue .userContentWrapper
$('#pagelet_pending_queue .userContentWrapper').each(function () {
var textContent = $(this).text();
var die = 0;
if (textContent.indexOf('đã phát trực tiếp') != -1) {
die = 1;
}
if (textContent.indexOf('was live') != -1) {
die = 1;
}
if (textContent.indexOf('is live now') != -1) {
die = 1;
}
if (textContent.indexOf('đang phát trực tiếp') != -1) {
die = 1;
}
if (textContent.indexOf('Đính kèm không khả dụng') != -1) {
die = 1;
}
if (textContent.indexOf('Attachment Unavailable') != -1) {
die = 1;
}
if (die == 1) {
if ($(this).find('a.profileLink').length > 0) {
var ajaxify = $(this).find('.profileLink').attr('ajaxify');
var groupId = ajaxify.match(/group_id=(\d+)/gm)[0].replace('group_id=', '');
var memberId = ajaxify.match(/member_id=(\d+)/gm)[0].replace('member_id=', '');
var check = KickMember(groupId, memberId, fb_dtsg);
if (check) {
banNum++;
//remove element
$(this).hide();
}
}
}
});
//numban
chrome.storage.sync.get("numBan", function (data) {
var numBan = data.numBan;
if (numBan == undefined || numBan == null) {
numBan = 1;
}
numBan = numBan + banNum;
chrome.storage.sync.set({numBan: numBan}, function () {
console.log("Increased banned user");
});
chrome.runtime.sendMessage({action: 'badgetText'});
});
}
}