Taipan_PC_Pro

Untitled

Aug 10th, 2018
787
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.09 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="vi">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Sharescript.net</title>
  6. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
  7. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/dataTables.bootstrap.min.css">
  8. <script src="//code.jquery.com/jquery.js"></script>
  9. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
  10. <script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
  11. <script src="https://cdn.datatables.net/1.10.15/js/dataTables.bootstrap.min.js"></script>
  12. <style type="text/css">
  13. body {
  14. background: #3332;
  15. }
  16. .container{
  17. margin-top: 15px;
  18. }
  19. .button-action{
  20. text-align: center;
  21. }
  22. .container > .row > .table tr.active th,
  23. .container > .row > .table tr.active td {
  24. background-color:#123456;
  25. color: white;
  26. font-weight: bold;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div class="container">
  32. <div class="row">
  33. <center><h2 style="color: blue;">TOOLS LỌC BẠN BÈ TƯƠNG TÁC</h2></center>
  34. <div class="panel panel-primary">
  35. <div class="panel-heading">
  36. <h3 class="panel-title">Lọc danh sách bạn bè không tương tác</h3>
  37. </div>
  38. <div class="panel-body">
  39. <div class="col-md-12">
  40. <div class="form-group">
  41. <input type="text" name="" id="accessToken" class="form-control" value="" required="required" placeholder="Nhập Mã Access Token Full Quyền">
  42. </div>
  43. </div>
  44. <div class="col-md-6">
  45. <div class="form-group">
  46. <label>Chọn Giới Tính</label>
  47. <select name="" id="gender" class="form-control" required="required" title="Giới Tính Bạn Bè Muốn Lọc">
  48. <option value="all">Tất Cả</option>
  49. <option value="male">Nam</option>
  50. <option value="female">Nữ</option>
  51. <option value="500fr">Bạn Bè Dưới 500</option>
  52. <option value="vn">Bạn Bè Là Người Nước Ngoài</option>
  53. </select>
  54. </div>
  55. </div>
  56. <div class="col-md-6">
  57. <div class="form-group">
  58. <label>Chọn Số Lượng Post</label>
  59. <select name="" id="total_post" class="form-control" required="required" title="Lượng Post Muốn Quét">
  60. <option value="10">10</option>
  61. <option value="20">20</option>
  62. <option value="50">50</option>
  63. <option value="50">100</option>
  64. <option value="200">200</option>
  65. <option value="10000">10000</option>
  66. </select>
  67. </div>
  68. </div>
  69. <div class="col-md-12">
  70. <div class="form-group button-action">
  71. <button type="button" class="btn btn-success" onclick="getListFriend();">Tiến Hành Lọc</button>
  72. <button type="button" class="btn btn-danger" onclick="Del_0_Point();">Xóa Bạn Có Điểm Tương Tác Bằng 0</button>
  73. <button type="button" class="btn btn-danger" onclick="Del_Selected();">Xóa Bạn Đã Chọn</button>
  74. </div>
  75. </div>
  76. <div class="col-md-12">
  77. <div class="alert alert-info" id="result-msg" style="display: none;">
  78.  
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="panel panel-primary" style="display: none;" id="ds-friends">
  84. <div class="panel-heading">
  85. <h3 class="panel-title">Danh Sách Xếp Hạng</h3>
  86. </div>
  87. <div class="panel-body">
  88. <div class="table-responsive">
  89. <table class="table table-bordered" width="100%" id="table-friends">
  90. </table>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. <script type="text/javascript">
  97. var _Friends = new Array();
  98. var _Comments = new Array();
  99. var _Reactions = new Array();
  100. $("#table-friends").on('click', 'tr', function() {
  101. $(this).toggleClass('active');
  102. });
  103. function getListFriend() {
  104. _TOKEN = $("#accessToken").val();
  105. if (!_TOKEN) {
  106. alert("Vui Lòng Nhập Mã Access Token Full Quyền!");
  107. return false;
  108. }
  109. $("#result-msg").html('<img src="https://www.drupal.org/files/issues/throbber_13.gif" width="30" height="30" /> Đang Lấy Thông Tin. Vui Lòng Đợi...').fadeIn("slow");
  110. var gender = $("#gender").val();
  111. if (gender == 'male') {
  112. var a = 'AND sex != \'female\'';
  113. var a = 'SELECT friend_count, uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex != "female" ORDER BY rand() LIMIT 5000';
  114.  
  115. } else if (gender == "female") {
  116. var a = 'SELECT friend_count, uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex != "male" ORDER BY rand() LIMIT 5000';
  117. } else if (gender == 'die'){
  118. var a = 'SELECT id, name FROM profile WHERE id IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND name = "Facebook User" ORDER BY rand() LIMIT 5000';
  119. } else if(gender == '500fr'){
  120. var a = 'SELECT friend_count, uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND friend_count < 500 ORDER BY rand() LIMIT 5000';
  121. } else if(gender == 'vn'){
  122. var a = 'SELECT locale, uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND locale != "vi_VN" ORDER BY rand() LIMIT 5000';
  123. } else if(gender == 'vn'){
  124. var a = 'SELECT locale, uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND locale != "vi_VN" ORDER BY rand() LIMIT 5000';
  125. } else {
  126. var a = 'SELECT uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY rand() LIMIT 5000';
  127. }
  128. $.ajax({
  129. url: "https://graph.facebook.com/fql",
  130. type: "GET",
  131. dataType: "JSON",
  132. data: {
  133. access_token: _TOKEN,
  134. q: a
  135. },
  136. success: (data) => {
  137. _Friends = data.data;
  138. getStatus();
  139. }
  140. })
  141. }
  142.  
  143. function showFriends(Data) {
  144. var arrFriends = new Array();
  145. $.each(Data, (i, item) => {
  146. arrFriends[i] = [
  147. (i + 1),
  148. '<img src="https://graph.facebook.com/' + item.uid + '/picture?width=30&height=30" /> <a target="_blank" href="https://fb.com/' + item.uid + '"> ' + item.name + '</a>',
  149. item.uid,
  150. item.reaction,
  151. item.comment,
  152. (item.comment * 2 + item.reaction) * 100
  153. ];
  154. })
  155. $('#table-friends').DataTable({
  156. destroy: true,
  157. data: arrFriends,
  158. columns: [{
  159. title: "STT"
  160. },
  161. {
  162. title: "FB NAME"
  163. },
  164. {
  165. title: "FB ID"
  166. },
  167. {
  168. title: "REACT"
  169. },
  170. {
  171. title: "COMMENT"
  172. },
  173. {
  174. title: "POINT"
  175. },
  176. ],
  177. "order": [
  178. [5, "desc"]
  179. ],
  180. "language": {
  181. "search": "Tìm Kiếm",
  182. "paginate": {
  183. "first": "Về Đầu",
  184. "last": "Về Cuối",
  185. "next": "Tiến",
  186. "previous": "Lùi"
  187. },
  188. "info": "Hiển thị _START_ đến _END_ của _TOTAL_ mục",
  189. "infoEmpty": "Hiển thị 0 đến 0 của 0 mục",
  190. "lengthMenu": "Hiển thị _MENU_ mục",
  191. "loadingRecords": "Đang tải...",
  192. "emptyTable": "Không có gì để hiển thị",
  193. }
  194. });
  195. }
  196.  
  197. function getStatus() {
  198. $("#result-msg").empty().html('<img src="https://www.drupal.org/files/issues/throbber_13.gif" width="30" height="30" /> Đang Lấy Thông Tin Tương Tác...');
  199. var limit = $("#total_post").val();
  200. $.ajax({
  201. url: "https://graph.facebook.com/me/feed",
  202. type: "GET",
  203. dataType: "JSON",
  204. data: {
  205. limit: limit,
  206. access_token: _TOKEN,
  207. fields: "id"
  208. },
  209. success: (data) => {
  210. getComments(data.data);
  211. getReactions(data.data);
  212. setTimeout((e) => {
  213. Ranking();
  214. }, 10000)
  215. }
  216. })
  217. }
  218.  
  219. function getReactions(Status) {
  220. var limit = 10000;
  221. for (var i = 0; i < Status.length; i++) {
  222. $.ajax({
  223. url: "https://graph.facebook.com/" + Status[i].id + "/",
  224. type: "GET",
  225. dataType: "JSON",
  226. data: {
  227. access_token: _TOKEN,
  228. fields: "reactions.limit(" + limit + ").summary(true)"
  229. },
  230. success: (data) => {
  231. if (data.reactions.data) {
  232. exPortReactions(data.reactions.data)
  233. }
  234. }
  235. })
  236. }
  237. }
  238.  
  239. function exPortReactions(Reactions) {
  240. for (var i = 0; i < Reactions.length; i++) {
  241. _Reactions.push(parseInt(Reactions[i].id));
  242. }
  243. }
  244.  
  245. function getComments(Status) {
  246. var limit = 1000;
  247. for (var i = 0; i < Status.length; i++) {
  248. $.ajax({
  249. url: "https://graph.facebook.com/" + Status[i].id + "/",
  250. type: "GET",
  251. dataType: "JSON",
  252. data: {
  253. access_token: _TOKEN,
  254. fields: "comments.limit(" + limit + ").summary(true)"
  255. },
  256. success: (data) => {
  257. if (data.comments.data) {
  258. getComments2(data.comments.data);
  259. }
  260. }
  261. })
  262. }
  263. }
  264.  
  265. function getComments2(Comments) {
  266. var limit = 2000
  267. for (var i = 0; i < Comments.length; i++) {
  268. _Comments.push(parseInt(Comments[i].from.id));
  269. $.ajax({
  270. url: "https://graph.facebook.com/" + Comments[i].id + "/",
  271. type: "GET",
  272. dataType: "JSON",
  273. data: {
  274. access_token: _TOKEN,
  275. fields: "comments.limit(" + limit + ").summary(true)"
  276. },
  277. success: (data) => {
  278. if (data.comments) {
  279. exPortComments(data.comments.data);
  280. }
  281. }
  282. })
  283. }
  284. }
  285.  
  286. function exPortComments(Comments) {
  287. for (var i = 0; i < Comments.length; i++) {
  288. _Comments.push(parseInt(Comments[i].from.id));
  289. }
  290. }
  291.  
  292. function Ranking() {
  293. $("#result-msg").empty().html('<img src="https://www.drupal.org/files/issues/throbber_13.gif" width="30" height="30" /> Đang Tính Toán Thứ Hạng ...');
  294. for (var i = 0; i < _Friends.length; i++) {
  295. _Friends[i].reaction = countItems(_Reactions, _Friends[i].uid);
  296. _Friends[i].comment = countItems(_Comments, _Friends[i].uid);
  297. }
  298. $("#ds-friends").fadeIn("slow");
  299. setTimeout((e) => {
  300. $("#result-msg").empty().html('<img src="http://uxotucung.org/wp-content/uploads/2016/03/tick-1-500x500.png" width="30" height="30" /> Thành Công!');
  301. show();
  302. }, 5000)
  303. }
  304.  
  305. function show() {
  306. showFriends(_Friends);
  307. }
  308.  
  309. function arrayCountValues(arr) {
  310. var v, freqs = {};
  311. for (var i = arr.length; i--;) {
  312. v = arr[i];
  313. if (freqs[v]) freqs[v] += 1;
  314. else freqs[v] = 1;
  315. }
  316. return freqs;
  317. }
  318.  
  319. function countItems(arr, what) {
  320. var count = 0,
  321. i;
  322. while ((i = arr.indexOf(what, i)) != -1) {
  323. ++count;
  324. ++i;
  325. }
  326. return count;
  327. }
  328. $("Del_0_Point").html('<img src="https://www.drupal.org/files/issues/throbber_13.gif" width="30" height="30" /> Đang Lấy Thông Tin. Vui Lòng Đợi...').fadeIn("slow");
  329.  
  330. function Del_0_Point() {
  331. $.each(_Friends, (i, item) => {
  332. if ((item.reaction + item.comment) === 0) {
  333. removeFriend(i, item);
  334. }
  335. })
  336. }
  337.  
  338. function Del_Selected() {
  339. var Data = $("#table-friends").DataTable().rows('.active').data();
  340. for (var i = 0; i < Data.length; i++) {
  341. removeFriend2(i, Data[i][2], Data[i][1].match(/"> (.*)</)[1]);
  342. }
  343. }
  344.  
  345. function removeFriend2(i, FBID, NAME) {
  346. ! function(i, FBID, NAME) {
  347. setTimeout(function() {
  348. $.ajax({
  349. url: 'https://graph.facebook.com/me/friends/' + FBID,
  350. type: "GET",
  351. dataType: "JSON",
  352. data: {
  353. access_token: _TOKEN,
  354. method: "delete",
  355. }
  356. }).done((e) => {
  357. $("#result-msg").fadeOut("slow", function() {
  358. $("#result-msg").empty().html('<img src="https://www.ochealthiertogether.org/content/global/application/indicators/gauges/target-met.png" width="20" height="20" /> Đã Xóa: <img src="https://graph.facebook.com/' + FBID + '/picture?width=30&height=30" /> ' + NAME + '(' + FBID + ')').fadeIn("slow");
  359. })
  360. }).error((e) => {
  361. $("#result-msg").fadeOut("slow", function() {
  362. $("#result-msg").empty().html('<img src="https://cdn.pixabay.com/photo/2017/02/12/21/29/false-2061132_960_720.png" width="20" height="20" /> Đã Xóa: <img src="https://graph.facebook.com/' + FBID + '/picture?width=30&height=30" /> ' + NAME + '(' + FBID + ')').fadeIn("slow");
  363. })
  364. })
  365. }, i * 500)
  366. }
  367. (i, FBID, NAME)
  368. }
  369.  
  370. function removeFriend(i, USER) {
  371. ! function(i, USER) {
  372. setTimeout(function() {
  373. $.ajax({
  374. url: 'https://graph.facebook.com/me/friends/' + USER.uid,
  375. type: "GET",
  376. dataType: "JSON",
  377. data: {
  378. access_token: _TOKEN,
  379. method: "delete",
  380. }
  381. }).done((e) => {
  382. $("#result-msg").fadeOut("slow", function() {
  383. $("#result-msg").empty().html('<img src="https://www.ochealthiertogether.org/content/global/application/indicators/gauges/target-met.png" width="20" height="20" /> Đã Xóa: <img src="https://graph.facebook.com/' + item.uid + '/picture?width=30&height=30" /> ' + USER.name + '(' + USER.uid + ')').fadeIn("slow");
  384. })
  385. }).error((e) => {
  386. $("#result-msg").fadeOut("slow", function() {
  387. $("#result-msg").empty().html('<img src="https://cdn.pixabay.com/photo/2017/02/12/21/29/false-2061132_960_720.png" width="20" height="20" /> Đã Xóa: <img src="https://graph.facebook.com/' + item.uid + '/picture?width=30&height=30" /> ' + USER.name + '(' + USER.uid + ')').fadeIn("slow");
  388. })
  389. })
  390. }, i * 300)
  391. }
  392. (i, USER)
  393. }
  394. </script>
  395. </body>
  396. </html>
Advertisement
Add Comment
Please, Sign In to add comment