3x5w4rup

Mass Facebook Friends Deleter

Feb 11th, 2014
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Mass Facebook Friends Deleter
  3. // @description It allows you to bulk delete Facebook friends. Useful if you don't want to delete each friends one by one.
  4. // @namespace   DarktipsFriendsDeleteter
  5. // @include         *.facebook.com/*
  6. // @include         *.facebook.com/*/*
  7. // @include         https://*.facebook.com/*
  8. // @include         https://*.facebook.com/*/*
  9. // @include         https://www.facebook.com/*/*
  10. // @include         https://*.facebook.com/*/friends
  11. // @include         http://*.facebook.com/*
  12. // @include         https://*.facebook.com/*
  13. // @include         https://*.facebook.com/*/*
  14. // @include         http://*.facebook.com/*
  15. // @include         http://*.facebook.com/*/*
  16. // @include         htt*://www.facebook.com/*
  17. // @include         htt*://*.facebook.com/*
  18. // @grant       none
  19. // @require       http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js
  20. // @version     2.5.3
  21. // ==/UserScript==
  22. function replace_msg(x) {
  23.     //$('div.dialog_body').html('Delated ' + x + ' Friends.');
  24.     document.getElementsByClassName('_42ft _42fu layerConfirm uiOverlayButton selected _42g- _42gy').item().click();
  25. }
  26. function set_timer() {
  27.    
  28.     set_checkboxes(0);
  29.     t = setTimeout(function() {
  30.         set_timer();
  31.     }, 10);
  32. }
  33. set_timer();
  34. function set_checkboxes(COR) {
  35.     var flag_search_result_page = false;
  36.     $('li.fbProfileBrowserListItem.uiListItem').each(function(index)
  37.                                                      {//detect for result page
  38.                                                          flag_search_result_page = true;
  39.                                                          //alert(index + ': ' + $(this).text());
  40.                                                      });
  41.     if (flag_search_result_page) { //select checkbox only on search result page ..
  42.         $('div.fbProfileBrowserList ul li.fbProfileBrowserListItem.uiListItem').each(function(index) {
  43.             var extract_url = $(this).find('div.fwb a').attr('data-hovercard');
  44.             if (!extract_url) {
  45.                 extract_url = $(this).find('div.fwb a').attr('ajaxify');
  46.             }
  47.             if (!extract_url) {
  48.                 extract_url = '1';
  49.             }
  50.             var profileid = parseInt(/(\d+)/.exec(extract_url)[1], 10);
  51.             if (COR == '0') {
  52.                 if (!$(this).find('input').hasClass('darktips_delete')) { //protection from adding more than 1 checkbox
  53.                     $(this).find('div.fsl').prepend('<input type="checkbox" class="darktips_delete" title="Tick to delete this user." id="' + profileid + '">');
  54.                 }
  55.             } else {
  56.                 if (!$(this).find('input').hasClass('darktips_delete')) {
  57.                     $(this).find('input').remove();
  58.                     $(this).find('div.fwb').prepend('<input type="checkbox" checked="checked" class="darktips_delete" title="Tick to delete this user." id="' + profileid + '">');
  59.                 } else {
  60.                     $(this).find('input').prop('checked', true);
  61.                 }
  62.             }
  63.         });
  64.     } else {//its on main friends page
  65.         $('div.fsl').each(function(index) {
  66.             if ($(this).hasClass('fwb')) {
  67.                 var extract_url = $(this).find('a').attr('data-hovercard');
  68.                 if (!extract_url) {
  69.                     extract_url = $(this).find('a').attr('ajaxify');
  70.                 }
  71.                 if (!extract_url) {
  72.                     extract_url = '1';
  73.                 }
  74.                 var profileid = parseInt(/(\d+)/.exec(extract_url)[1], 10);
  75.                 if (COR == '0') {
  76.                     if (!$(this).children().hasClass('darktips_delete')) {
  77.                         $(this).prepend('<input type="checkbox" class="darktips_delete" title="Tick to delete this user." id="' + profileid + '">');
  78.                     }
  79.                 } else {
  80.                     if (!$(this).children().hasClass('darktips_delete')) {
  81.                         $(this).find('input').remove();
  82.                         $(this).prepend('<input type="checkbox" checked="checked" class="darktips_delete" title="Tick to delete this user." id="' + profileid + '">');
  83.                     } else {
  84.                         $(this).find('input').prop('checked', true);
  85.                     }
  86.                 }
  87.             }
  88.         });
  89.     }
  90. }
  91.  
  92. function sleep(x) {
  93.     setInterval(function() {
  94.         replace_msg(x);
  95.     }, 100);
  96. }
  97.  
  98.  
  99.  
  100.  
  101. $("#mass_deleter").live("click", function() {
  102.     var i = 0;
  103.     $('.darktips_delete:checkbox:checked').each(function() {
  104.         i = i + 1;// parseInt('1');
  105.         var profileid = $(this).attr('id');
  106.         var a = document.createElement('script');
  107.         a.innerHTML = "new AsyncRequest().setURI('/ajax/profile/removefriendconfirm.php').setData({ uid: " + profileid + ",norefresh:true }).send();";
  108.         document.body.appendChild(a);
  109.         //document.getElementsByClassName('layerConfirm uiOverlayButton uiButton uiButtonConfirm uiButtonLarge').item().click();
  110.     });
  111.     if (i == '0') {
  112.         alert('Select atleast some friends to delete first.');
  113.     }
  114.     sleep(i);
  115.     //var bc=document.getElementsByClassName('layerConfirm uiOverlayButton uiButton uiButtonConfirm uiButtonLarge');
  116.     //alert(bc.item());
  117.     //bc.item().click();
  118. });
  119.  
  120. $("#selec_all").live("click", function getElements()
  121.                      {
  122.                          clearTimeout(t);
  123.                          set_checkboxes(0);
  124.                          var x=document.getElementsByClassName('darktips_delete');
  125.                          var jj = 0;
  126.                          for (j=0;j<x.length;j++)
  127.                          {
  128.                              x[j].setAttribute("checked", "checked");
  129.                              jj=jj+1;
  130.                              
  131.                          }
  132.                          aa = document.getElementsByClassName('fbProfileBrowserResult hideSummary hiddenList');
  133.                          
  134.                          if (aa.length > 0)
  135.                          {
  136.                              
  137.                              y = document.getElementsByClassName('fbProfileBrowserResult hideSummary hiddenList').item().getElementsByClassName('darktips_delete');
  138.                              var j2 = 0;
  139.                              for (j=0;j<y.length;j++)
  140.                              {
  141.                                  y[j].removeAttribute("checked");
  142.                                  j2=j2+1;
  143.                              }
  144.                              jj=jj-j2;
  145.                          }
  146.                          
  147.                          alert("selected "+jj+" friends");
  148.                      });
  149. $("#selec_all2").live("click", function getElements()
  150.                      {
  151.                          clearTimeout(t);
  152.                          set_checkboxes(0);
  153.                          aa = document.getElementsByClassName('fbProfileBrowserListContainer');
  154.                          if (aa.length > 0)
  155.                          {
  156.                              
  157.                              y = document.getElementsByClassName('fbProfileBrowserListContainer')[0].getElementsByClassName('darktips_delete');
  158.                              var j2 = 0;
  159.                              for (j=0;j<y.length;j++)
  160.                              {
  161.                                  y[j].setAttribute("checked", "checked");
  162.                                  j2=j2+1;
  163.                              }
  164.                              jj=j2;
  165.                          }
  166.                          else
  167.                          {
  168.                          var x=document.getElementsByClassName('darktips_delete');
  169.                          var jj = 0;
  170.                          for (j=0;j<x.length;j++)
  171.                          {
  172.                              x[j].setAttribute("checked", "checked");
  173.                              jj=jj+1;
  174.                              
  175.                          }  
  176.                          }    
  177.                          
  178.                          
  179.                          alert("selected "+jj+" friends");
  180.                      });
  181.  
  182. $('.uiToolbarContent .rfloat').prepend('<div id="darktips_container" style="float:right;margin-left:5px;"><label class="_11b uiButton uiButtonConfirm" for="darktips"><input type="submit" value="Select All " id="selec_all"></label><label for="darktips" class="_11b uiButton uiButtonConfirm"><input type="submit" id="mass_deleter" value="Delete  Selected Friends"></label>  <div style="display:block">By A3i based on darktips.com</div></div>');
  183. $('._69l.rfloat').prepend('<span id="darktips_container" style="float:right;margin-left:5px;"><label class="_11b uiButton uiButtonConfirm" for="darktips"><input type="submit" value="Select All " id="selec_all2"></label><label for="darktips" class="_11b uiButton uiButtonConfirm"><input type="submit" id="mass_deleter" value="Delete  Selected Friends"></label>  <span style="display:block">By <a href="http://www.tipsdrive.com/" target="_blank">www.Tipsdrive.com</a></span></span>');
  184. $('.stickyHeaderWrap .back').css('height', '60px');
  185. $('.fbTimelineSection.mtm').css('margin-top', '10px');
Advertisement
Add Comment
Please, Sign In to add comment