Delete Selected Friends with Single Click

This script is select multiple friends on Facebook and Unfriend them with single click

  1. // ==UserScript==
  2. // @name Delete Selected Friends with Single Click
  3. // @description This script is select multiple friends on Facebook and Unfriend them with single click
  4. // @namespace Naveen
  5. // @include *.facebook.com/*
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js
  7. // @version 3.0
  8. // ==/UserScript==
  9. // Developed by Naveen - http://webaspirants.com
  10.  
  11.  
  12. function replace_msg(x) {
  13. //$('div.dialog_body').html('Whuuuhuu! ' + x + ' friends has been deleted. Join us at <a href="http://fb.com/webaspirants" rel="nofollow">Naveen</a> for more useful tips/tricks and more!');
  14. document.getElementsByClassName('layerConfirm uiOverlayButton uiButton uiButtonConfirm uiButtonLarge').item().click();
  15. }
  16. function set_timer() {
  17. set_checkboxes(0);
  18. t = setTimeout(function() {
  19. set_timer();
  20. }, 10);
  21. }
  22. set_timer();
  23. function set_checkboxes(COR) {
  24. var flag_search_result_page = false;
  25. $('li.fbProfileBrowserListItem.uiListItem').each(function(index)
  26. {//detect for result page
  27. flag_search_result_page = true;
  28. //alert(index + ': ' + $(this).text());
  29. });
  30. if (flag_search_result_page) { //select checkbox only on search result page ..
  31. $('div.fbProfileBrowserList ul li.fbProfileBrowserListItem.uiListItem').each(function(index) {
  32. var extract_url = $(this).find('div.fwb a').attr('data-hovercard');
  33. if (!extract_url) {
  34. extract_url = $(this).find('div.fwb a').attr('ajaxify');
  35. }
  36. if (!extract_url) {
  37. extract_url = '1';
  38. }
  39. var profileid = parseInt(/(\d+)/.exec(extract_url)[1], 10);
  40. if (COR == '0') {
  41. if (!$(this).find('input').hasClass('mudra_delete')) { //protection from adding more than 1 checkbox
  42. $(this).find('div.fsl').prepend('<input type="checkbox" class="mudra_delete" title="Tick to delete this user." id="' + profileid + '">');
  43. }
  44. } else {
  45. if (!$(this).find('input').hasClass('mudra_delete')) {
  46. $(this).find('input').remove();
  47. $(this).find('div.fwb').prepend('<input type="checkbox" checked="checked" class="mudra_delete" title="Tick to delete this user." id="' + profileid + '">');
  48. } else {
  49. $(this).find('input').prop('checked', true);
  50. }
  51. }
  52. });
  53. } else {//its on main friends page
  54. $('div.fsl').each(function(index) {
  55. if ($(this).hasClass('fwb')) {
  56. var extract_url = $(this).find('a').attr('data-hovercard');
  57. if (!extract_url) {
  58. extract_url = $(this).find('a').attr('ajaxify');
  59. }
  60. if (!extract_url) {
  61. extract_url = '1';
  62. }
  63. var profileid = parseInt(/(\d+)/.exec(extract_url)[1], 10);
  64. if (COR == '0') {
  65. if (!$(this).children().hasClass('mudra_delete')) {
  66. $(this).prepend('<input type="checkbox" class="mudra_delete" title="Tick to delete this user." id="' + profileid + '">');
  67. }
  68. } else {
  69. if (!$(this).children().hasClass('mudra_delete')) {
  70. $(this).find('input').remove();
  71. $(this).prepend('<input type="checkbox" checked="checked" class="mudra_delete" title="Tick to delete this user." id="' + profileid + '">');
  72. } else {
  73. $(this).find('input').prop('checked', true);
  74. }
  75. }
  76. }
  77. });
  78. }
  79. }
  80.  
  81. function sleep(x) {
  82. setInterval(function() {
  83. replace_msg(x);
  84. }, 100);
  85. }
  86.  
  87.  
  88.  
  89.  
  90. $("#mass_deleter").live("click", function() {
  91. var i = 0;
  92. $('.mudra_delete:checkbox:checked').each(function() {
  93. i = i + 1;// parseInt('1');
  94. var profileid = $(this).attr('id');
  95. var a = document.createElement('script');
  96. a.innerHTML = "new AsyncRequest().setURI('/ajax/profile/removefriendconfirm.php').setData({ uid: " + profileid + ",norefresh:true }).send();";
  97. document.body.appendChild(a);
  98. //document.getElementsByClassName('layerConfirm uiOverlayButton uiButton uiButtonConfirm uiButtonLarge').item().click();
  99. });
  100. if (i == '0') {
  101. alert('Select atleast some friends to delete first.');
  102. }
  103. sleep(i);
  104. //var bc=document.getElementsByClassName('layerConfirm uiOverlayButton uiButton uiButtonConfirm uiButtonLarge');
  105. //alert(bc.item());
  106. //bc.item().click();
  107. });
  108.  
  109. $("#selec_all").live("click", function getElements()
  110. {
  111. clearTimeout(t);
  112. set_checkboxes(0);
  113. var x=document.getElementsByClassName('mudra_delete');
  114. var jj = 0;
  115. for (j=0;j<x.length;j++)
  116. {
  117. x[j].setAttribute("checked", "checked");
  118. jj=jj+1;
  119. }
  120. aa = document.getElementsByClassName('fbProfileBrowserResult hideSummary hiddenList');
  121. if (aa.length > 0)
  122. {
  123. y = document.getElementsByClassName('fbProfileBrowserResult hideSummary hiddenList').item().getElementsByClassName('mudra_delete');
  124. var j2 = 0;
  125. for (j=0;j<y.length;j++)
  126. {
  127. y[j].removeAttribute("checked");
  128. j2=j2+1;
  129. }
  130. jj=jj-j2;
  131. }
  132. alert("selected "+jj+" friends");
  133. });
  134.  
  135. $('.uiToolbarContent .rfloat').prepend('<div id="mudra_container" style="float:right;margin-left:5px;"><label class="_11b uiButton uiButtonConfirm" for="mudra"><input type="submit" value="Select All Friends" id="selec_all"></label><label for="mudra" class="_11b uiButton uiButtonConfirm"><input type="submit" id="mass_deleter" value="Delete Selected Friends"></label> <div style="display:block">By Naveen</div></div>');
  136. $('._69l.rfloat').prepend('<span id="mudra_container" style="float:right;margin-left:5px;"><label class="_11b uiButton uiButtonConfirm" for="mudra"><input type="submit" value="Select All Friends" id="selec_all"></label><label for="mudra" class="_11b uiButton uiButtonConfirm"><input type="submit" id="mass_deleter" value="Delete Selected Friends"></label> <span style="display:block">By Mudra</span></span>');
  137. $('.stickyHeaderWrap .back').css('height', '60px');
  138. $('.fbTimelineSection.mtm').css('margin-top', '10px');