Inviter

facebook invite

  1. // ==UserScript==
  2. // @name Inviter
  3. // @namespace http://codeot.com
  4. // @version 0.1
  5. // @description facebook invite
  6. // @author Talha Habib
  7. // @email talha@codeot.com
  8. // @match *://*.facebook.com/*
  9. // ==/UserScript==
  10.  
  11. // -- start
  12.  
  13. function inviteAll(){
  14. console.log("firing");
  15. appendHTML(document.querySelector(".status_mt"),"<p>Firing inviter</p>");
  16. for(var i=0; i<=document.querySelectorAll('._5i_q span ._42ft:not(._42fr):not(._59pe)').length;i++){
  17. setTimeout(Inviter,3000*i,i,document.querySelectorAll('._5i_q span ._42ft:not(._42fr):not(._59pe)').length);
  18. }
  19. }
  20. function Inviter(i,l){
  21. console.log("Invited "+ parseInt(i+1) +" Out of "+l);
  22. appendHTML(document.querySelector(".status_mt"),"<p>Invited "+ parseInt(i+1) +" Out of "+l+"</p>");
  23. if(parseInt(i+1)==l){
  24. console.log("Trigger new");
  25. appendHTML(document.querySelector(".status_mt"),"<p>Reached End of Block</p>");
  26. if(document.querySelectorAll("a[rel='async'].pam").length==1){
  27. loadMore();
  28. console.log("Got some more");
  29. appendHTML(document.querySelector(".status_mt"),"<p>Got some more</p>");
  30. setTimeout(inviteAll,5000);
  31. }else{
  32. console.log("--------------Closing-----------------");
  33. console.log("Invited all of them");
  34. appendHTML(document.querySelector(".status_mt"),"<p>Invited all of them</p>");
  35. appendHTML(document.querySelector(".status_mt"),"<p>Closing in 2 seconds</p>");
  36. setTimeout(function(){
  37. document.querySelector(".status_mt").remove();
  38. },2000);
  39. }
  40. }else{
  41. if(document.querySelectorAll('._5i_q span ._42ft:not(._42fr):not(._59pe)').length>0){
  42. document.querySelectorAll('._5i_q span ._42ft:not(._42fr):not(._59pe)')[i].click();
  43. }else{
  44. console.log("Nothing to invite");
  45. appendHTML(document.querySelector(".status_mt"),"<p>Nothing to invite</p>");
  46. console.log("Checking more entries");
  47. appendHTML(document.querySelector(".status_mt"),"<p>Checking more entries</p>");
  48. if(document.querySelectorAll("a[rel='async'].pam").length==1){
  49. console.log("Loading more");
  50. appendHTML(document.querySelector(".status_mt"),"<p>Loading more...</p>");
  51. loadMore();
  52. setTimeout(inviteAll,5000);
  53. }else{
  54. console.log("Nothing found");
  55. appendHTML(document.querySelector(".status_mt"),"<p>Nothing found</p>");
  56. return false;
  57. }
  58. }
  59. }
  60. }
  61. function loadMore(){
  62. document.querySelectorAll("a[rel='async'].pam")[0].click();
  63. }
  64. document.addEventListener ("keydown", function (zEvent) {
  65. if (zEvent.ctrlKey && zEvent.altKey && zEvent.code === "KeyG") {
  66. if(document.querySelectorAll(".status_mt").length==0){
  67. appendHTML(document.body,'<div class="status_mt" style="overflow:auto;position:absolute;top:0;left:0;width:300px;height:300px;background:white;z-index:99999;padding:10px"></div>');
  68. }
  69. appendHTML(document.querySelector(".status_mt"),"<p>Key Detected</p>");
  70. console.log("Key Detected");
  71. inviteAll();
  72. }
  73. });
  74.  
  75. function appendHTML(element,html){
  76. var t = parseHTML(html);
  77. element.insertBefore(t, element.firstChild);
  78. }
  79. function parseHTML(html) {
  80. var t = document.createElement('template');
  81. t.innerHTML = html;
  82. return t.content.cloneNode(true);
  83. }
  84. // -- end