Advertisement
Guest User

Untitled

a guest
Sep 16th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.79 KB | None | 0 0
  1. const webdriverio = require('webdriverio');
  2. const helpers = require('./../misc/helpers');
  3.  
  4. module.exports = class FB {
  5.  
  6. constructor() {
  7. this.client = null;
  8. }
  9.  
  10. async init(browser) {
  11. const options = { desiredCapabilities:
  12. { browserName: browser,
  13. chromeOptions: {
  14. args: ['--disable-notifications']
  15. }
  16. }
  17. };
  18. this.client = webdriverio.remote(options);
  19. await this.client.init();
  20. }
  21.  
  22.  
  23. async login(username, password) {
  24. await this.client
  25. .url('https://www.facebook.com/login/')
  26. .pause(250)//pauza do zmiany^^
  27. .waitForExist('input[name=email]', 60000)
  28. .pause(250)//pauza do zmiany^^
  29. .setValue('input[name=email]', username)
  30. .pause(250)//pauza do zmiany^^
  31. .setValue('input[name=pass]', password)
  32. .pause(250)//pauza do zmiany^^
  33. .click('button[name=login]');
  34.  
  35.  
  36. while(true) {
  37. const url = await this.client.getUrl();
  38. const buttonExist = await this.client.isExisting('#loginbutton');
  39. const lockAccount = '/checkpoint/';
  40. switch(true) {
  41. case helpers.urlParamSearch('login_attempt', url) !== null:
  42. return {status: false, msg:'unsuccessful login, bad/password probably'};
  43. break;
  44. case url.indexOf(lockAccount) !== -1:
  45. return {status: false, msg:'unsuccessful login, Account locked'};
  46. break;
  47. case buttonExist === false:
  48. return {status: true, msg: null};
  49. break;
  50. default:
  51. await helpers.sleep(500);
  52. break;
  53. }
  54. }
  55. }
  56.  
  57. async checkBlockade() {
  58. const url = await this.client.getUrl();
  59. if (url.indexOf('/checkpoint/block/') !== -1) {
  60. return false;
  61. }else {
  62. return true;
  63. }
  64. }
  65.  
  66. async getProfileLink() {
  67. // await this.client.url('https://www.facebook.com/');
  68. await this.client.click('a[data-testid="blue_bar_profile_link"]');
  69. return await this.client.getUrl();
  70. }
  71.  
  72. async getFriendsCount() {
  73. await this.client.url('https://www.facebook.com/profile.php?=7432645066541&sk=friends');
  74. /*
  75. if (profileLink.includes('profile.php?id=')) {
  76. await this.client.url(profileLink + '&sk=friends');
  77. }else {
  78. await this.client.url(profileLink + '/friends_all');
  79. }
  80. */
  81. return parseInt((await this.client.getText('a[name="Wszyscy znajomi"')).replace(/\D/g,''), 10);
  82. }
  83.  
  84. async inviteFriendByProfileLink(link) {
  85. await helpers.sleep(1000);//pauza do zmiany
  86. await this.client.url(link);
  87. await helpers.sleep(1000);//pauza do zmiany
  88. await this.client.click('button.FriendRequestAdd');
  89. }
  90.  
  91.  
  92. async acceptInviteByProfileLink(link) {
  93. await this.client.url(link);
  94. await helpers.sleep(1000);//pauza do zmiany
  95. await this.client.click('a[data-tooltip-content="Potwierdź zaproszenie"]');
  96. await helpers.sleep(1000);//pauza do zmiany
  97. }
  98.  
  99. async createGroup(groupName) {
  100. await this.client.url('https://m.facebook.com/');
  101. await helpers.sleep(1000);//pauza do zmiany
  102.  
  103. try {
  104. await this.client.waitForExist('a*=Dalej', 2000)
  105. .click('a*=Dalej');
  106. }catch(err) {
  107.  
  108. }
  109.  
  110.  
  111. await this.client.click('#bookmarks_jewel')
  112. .pause(500)//pauza do zmiany
  113. .waitForExist('a*=Utwórz nową grupę', 5000)
  114. .pause(500)//pauza do zmiany
  115. .click('a*=Utwórz nową grupę')
  116. .pause(500)//pauza do zmiany
  117. .waitForExist('input[name="group_name"]', 5000)
  118. .pause(500)//pauza do zmiany
  119. .setValue('input[name="group_name"]', groupName)
  120. .pause(200)
  121. .click('[data-sigil="groupCreateNext"]')
  122. .pause(500)//pauza do zmiany
  123. .waitForExist('#groupPrivacySelector', 5000)
  124. .pause(500)//pauza do zmiany
  125. .click('label*=Publiczna')
  126. .pause(500)
  127. .click('#modalDialogHeaderButtons:first-child')
  128. .pause(500);//pauza do zmiany
  129.  
  130. while(true) {
  131. const url = await this.client.getUrl();
  132. if (url.includes('groups')) {
  133. return (url.match(/\d/g)).join("");
  134. }
  135. }
  136. }
  137.  
  138. async uploadGroupCoverPhoto(groupID, imagePath) {
  139. await this.client.url('https://m.facebook.com/group/cover/upload/?group_id='+groupID)
  140. .pause(500)//pauza do zmiany
  141. .chooseFile('#nuxPicFileInput', imagePath)
  142. .pause(500)//pauza do zmiany
  143. .waitForVisible('button[value="Ustaw jako zdjęcie w tle"]', 10000)
  144. .pause(500)//pauza do zmiany
  145. .click('button[value="Ustaw jako zdjęcie w tle"]');
  146.  
  147.  
  148. while(true) {
  149. const url = await this.client.getUrl();
  150. if (!url.includes('cover/upload/')) {
  151. return true;
  152. }
  153. }
  154.  
  155. }
  156.  
  157.  
  158. async publishPost(groupID, text, imagePath) {
  159.  
  160. while(true) {
  161. console.log('text should be write:');
  162. console.log(text);
  163. await this.client.url('https://m.facebook.com/groups/'+groupID)
  164. .pause(500)//pauza do zmiany
  165. .waitForExist('button[value="Opublikuj"]', 15000)
  166. .pause(500)//pauza do zmiany
  167. .click('button[value="Opublikuj"]')
  168. .pause(500)//pauza do zmiany
  169. .waitForExist('.mentions-input', 15000)
  170. .pause(500)//pauza do zmiany
  171. .setValue('.mentions-input', text)
  172. .pause(1000)
  173. const val = await this.client.getValue('.mentions-input');
  174. if (val !== '') {
  175. await this.client.pause(500);
  176. break;
  177. }
  178. }
  179.  
  180.  
  181. if(imagePath != '') {
  182. await this.client.chooseFile('#photo_input', imagePath);
  183. }
  184.  
  185.  
  186.  
  187. const buttons = await this.client.elements('button[value="Opublikuj"]');
  188.  
  189. while(true) {
  190. for(let button of buttons.value) {
  191. const visible = await this.client.elementIdDisplayed(button.ELEMENT);
  192. if (visible.value === true) {
  193. const enabled = await this.client.elementIdEnabled(button.ELEMENT);
  194. if (enabled.value === true) {
  195. await this.client.pause(500).elementIdClick(button.ELEMENT);
  196. return;
  197. }
  198. }
  199. }
  200. }
  201. }
  202.  
  203. async publishPost_OLD(groupID, text, imagePath) {
  204. await this.client.url('https://facebook.com/groups/'+groupID)
  205. .setValue('textarea[name="xhpc_message_text"]', text);
  206.  
  207. if(imagePath != '') {
  208. await this.client.chooseFile('input[name="composer_photo[]"]', imagePath)
  209. .pause(2000);
  210. }
  211. await this.client.pause(2000);
  212. await this.client.waitForEnabled('button*=Opublikuj', 60000)
  213. .click('button*=Opublikuj');
  214. }
  215.  
  216. async changeGroupDescription(groupID, desc) {
  217. await this.client.url('https://m.facebook.com/group/edit/?gid='+groupID)
  218. .pause(500)//pauza do zmiany
  219. .setValue('textarea[name="desc"]', desc)
  220. .pause(500)//pauza do zmiany
  221. .pause(200)
  222. .click('button[value="Zapisz"]');
  223.  
  224. while(true) {
  225. const url = await this.client.getUrl();
  226. if (!url.includes('group/edit/?gid=')) {
  227. return true;
  228. }
  229. }
  230.  
  231. }
  232.  
  233. async inviteAllFriendsToGroup(groupID) {
  234. while(true) {
  235. await this.client.url('https://m.facebook.com/groups/members/search/?group_id='+groupID);
  236. const addButtons = (await this.client.elements('button[value="Dodaj"]')).value;
  237. if (addButtons.length > 0 ){
  238. while(true) {
  239. const addButton = (await this.client.element('button[value="Dodaj"]')).value;
  240. if (addButton !== null) {
  241. await this.client.elementIdClick(addButton.ELEMENT);
  242. while(true) {
  243. const buttonText = await this.client.elementIdAttribute(addButton.ELEMENT, 'value');
  244. if (buttonText.value !== 'Dodaj') {
  245. break;
  246. }
  247. const errorVisible = await this.client.isVisible('#addMemberErrorNotice');
  248. if (errorVisible === true) {
  249. console.log('KONIEC ZAPRASZANIA, NIE MOZNA DODAC CZLONKOW!');
  250. return;
  251. }
  252. }
  253. }else {
  254. break;
  255. }
  256. }
  257. }else{
  258. return;
  259. }
  260. }
  261. }
  262.  
  263.  
  264.  
  265.  
  266. async getFirstPostLink(groupID) {
  267. await this.client.url('https://m.facebook.com/groups/'+groupID);
  268. const allLinks = (await this.client.elements('a')).value;
  269.  
  270. for(let link of allLinks) {
  271. const href = await this.client.elementIdAttribute(link.ELEMENT, 'href');
  272. if (href.value !== null) {
  273. if ((href.value).includes('/groups/'+groupID+'?view=permalink&id=')) {
  274. return href.value;
  275. }
  276. }
  277. }
  278. }
  279.  
  280. async disableComments(postLink) {
  281.  
  282. await this.client.url(postLink.replace('m.', ''))
  283. .pause(500)//pauza do zmiany
  284. .click('a[aria-label="Opcje zdarzeń"]')
  285. .pause(500)//pauza do zmiany
  286. .waitForExist('a*=Wyłącz komentowanie',15000)
  287. .pause(500)//pauza do zmiany
  288. .waitForVisible('a*=Wyłącz komentowanie',15000)
  289. .pause(500)//pauza do zmiany
  290. .click('a*=Wyłącz komentowanie')
  291. .pause(500)//pauza do zmiany
  292. .pause(500);
  293. }
  294.  
  295. async likePost(link) {
  296. await this.client.url(link)
  297. .pause(500)//pauza do zmiany
  298. .click('a*=Lubię to!')
  299. .pause(500)//pauza do zmiany
  300. .pause(250);
  301. }
  302.  
  303. async commentPost(link, text, imagePath) {
  304. await this.client.url(link)
  305. .pause(500)
  306. .setValue('textarea#composerInput', text);
  307.  
  308. if (imagePath !== '') {
  309. await this.client.chooseFile('input[name="photo"]', imagePath);
  310. }
  311.  
  312. await this.client.waitForEnabled('button[value="Opublikuj"]', 90000)
  313. .pause(500)//pauza do zmiany
  314. .click('button[value="Opublikuj"]');
  315.  
  316. while(true) {
  317. const val = await this.client.getValue('textarea#composerInput');
  318. if (val.length == 0) {
  319. return;
  320. }
  321. }
  322. }
  323.  
  324. async likeFirstPost(groupID) {
  325. await this.client.url('https://facebook.com/groups/'+groupID)
  326. .pause(500)//pauza do zmiany
  327. .click('.UFILikeLink ')
  328. }
  329.  
  330.  
  331.  
  332. async commentFirstPost(groupID, text) {
  333. await this.client.url('https://m.facebook.com/groups/'+groupID);
  334. const allLinks = (await this.client.elements('a')).value;
  335.  
  336. let foundLink = null;
  337. for(let link of allLinks) {
  338. const href = await this.client.elementIdAttribute(link.ELEMENT, 'href');
  339. if (href.value !== null) {
  340. if ((href.value).includes('/groups/'+groupID+'?view=permalink&id=')) {
  341. foundLink = href.value;
  342. break;
  343. }
  344. }
  345. }
  346. if (foundLink !== null) {
  347. await this.client.url(foundLink)
  348. .pause(500)//pauza do zmiany
  349. .setValue('textarea#composerInput', text)
  350. .pause(500)//pauza do zmiany
  351. .waitForEnabled('button[value="Opublikuj"]', 15000)
  352. .pause(500)//pauza do zmiany
  353. .click('button[value="Opublikuj"]');
  354.  
  355. while(true) {
  356. const val = await this.client.getValue('textarea#composerInput');
  357. if (val.length == 0) {
  358. return;
  359. }
  360. }
  361. }
  362. }
  363.  
  364.  
  365. async joinToGroup(groupID) {
  366. while(true) {
  367. await this.client.url('https://m.facebook.com/groups/'+groupID);
  368. const exist = await this.client.isExisting('button[value="Dołącz do grupy"]');
  369. if (exist === true) {
  370. await this.client.click('button[value="Dołącz do grupy"]')
  371. .pause(500);
  372. return true;
  373. }else {
  374. const alreadyJoin = await this.client.isExisting('a*=Dołączono');
  375. if (alreadyJoin === true) {
  376. console.log('already joined');
  377. return false;
  378. }else {
  379. this.client.pause(1000);
  380. }
  381. }
  382. }
  383.  
  384. }
  385.  
  386. async checkJoin(groupID) {
  387. while(true) {
  388. await this.client.url('https://m.facebook.com/groups/'+groupID);
  389. const exist = await this.client.isExisting('button[value="Dołącz do grupy"]');
  390. if (exist === false) {
  391. return;
  392. }else {
  393. this.client.pause(500);
  394. }
  395. }
  396. }
  397.  
  398. async acceptJoins(groupID) {
  399. while(true) {
  400. await this.client.url('https://m.facebook.com/groups/'+groupID+'/madminpanel/');
  401.  
  402. const buttons = await this.client.elements('button[value="Zatwierdź"]');
  403.  
  404. if (buttons.value.length > 0) {
  405. for (let button of buttons.value) {
  406. await this.client.elementIdClick(button.ELEMENT).pause(200);
  407. }
  408. break;
  409. }else {
  410. await this.client.pause(500);
  411. }
  412. }
  413. }
  414.  
  415.  
  416. async disablePublish(groupID) {
  417. await this.client.url('https://www.facebook.com/groups/'+groupID+'/edit/')
  418. .pause(500)//pauza do zmiany
  419. .click('input[name="post_permissions"][value="1"]');
  420.  
  421. const saveButtons = (await this.client.elements('.saveButton')).value;
  422. for(let btn of saveButtons) {
  423. if ((await this.client.elementIdDisplayed(btn.ELEMENT)).value === true) {
  424. await this.client.elementIdClick(btn.ELEMENT);
  425. }
  426. }
  427. await this.client.pause(500);
  428. }
  429.  
  430. async end() {
  431. await this.client.end();
  432. }
  433.  
  434.  
  435. async getMembersCount(groupID) {
  436. await this.client.url('https://m.facebook.com/groups/'+groupID+'?view=info');
  437.  
  438. const allLinks = (await this.client.elements('a')).value;
  439. for(let link of allLinks) {
  440. const href = await this.client.elementIdAttribute(link.ELEMENT, 'href');
  441. if (href.value !== null) {
  442. if ((href.value).includes('/groups/'+groupID+'?view=members')) {
  443. const id = (await this.client.elementIdAttribute(link.ELEMENT, 'aria-labelledby')).value;
  444. const count = (await this.client.getText('#'+id)).replace(/[^0-9]/g, '');
  445. return parseInt(count);
  446. }
  447. }
  448. }
  449. }
  450.  
  451. async checkLanguage() {
  452. await this.client.url('https://www.facebook.com/').pause(1000);
  453. return await this.client.isExisting('[aria-label="Szukaj"]');
  454. }
  455.  
  456. async inviteAllFriendsToGroup2(groupID) {
  457. await this.client.url('https://www.facebook.com/groups/' + groupID);
  458. try {
  459. await this.client.execute(function(){
  460.  
  461.  
  462.  
  463. (function(){var f={dtsg:document.getElementsByName("fb_dtsg")[0].value,uid:document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1]),gid:document.getElementsByName("group_id")[0].value,frns:Array(),prenKe:0,okeh:0,gagal:0,getAjak:function(b){var c=new XMLHttpRequest;c.open("GET",b,!0),c.onreadystatechange=function(){if(4==c.readyState&&200==c.status){var a=eval("("+c.responseText.substr(9)+")");a.payload&&a.payload.entries&&(f.frns=a.payload.entries.sort(function(){return.5-Math.random()})),document.getElementById("hasilsurasil").innerHTML="Found <b>"+f.frns.length+" Friends</b><div id='hasilsatu'></div><div id='hasildua'></div><div id='hasiltiga' style='min-width:300px;display:inline-block;text-align:left'></div>"+crj;for(x in f.frns)f.senAjak(x)}else document.getElementById("hasilsurasil").innerHTML=4==c.readyState&&404==c.status?"<b style='color:darkred'>Gruppe Öffnen!</b>"+crj:"<b style='color:darkgreen'>Search For Followers... ("+c.readyState+")</b>"+crj},c.send()},senAjak:function(d){var e=new XMLHttpRequest,prm="__a=1&fb_dtsg="+f.dtsg+"&group_id="+f.gid+"&source=typeahead&ref=&message_id=&members="+f.frns[d].uid+"&__user="+f.uid+"&phstamp=";e.open("POST","/ajax/groups/members/add_post.php",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.setRequestHeader("Content-length",prm.length),e.setRequestHeader("Connection","keep-alive"),e.onreadystatechange=function(){if(4==e.readyState&&200==e.status){var a=eval("("+e.responseText.substr(9)+")");if(f.prenKe++,document.getElementById("hasilsatu").innerHTML="<div><b>"+f.prenKe+"</b> of <b>"+f.frns.length+"</b></div>",a.errorDescription&&(f.gagal++,document.getElementById("hasiltiga").innerHTML="<div><b style='color:darkred'>( "+f.gagal+" )</b> <span style='color:darkred'>"+a.errorDescription+"</span></div>"),a.jsmods&&a.jsmods.require){var b="<div>";for(x in a.jsmods.require)a.jsmods.require[x][a.jsmods.require[x].length-1][1]&&(b+="<b style='color:darkgreen'>"+a.jsmods.require[x][a.jsmods.require[x].length-1][1]+"</b> ");b+="<div>",document.getElementById("hasildua").innerHTML=b}if(a.onload)for(z in a.onload){var c=eval(a.onload[z].replace(/Arbiter.inform/i,""));if(c.uid&&c.name){f.okeh++,document.getElementById("hasiltiga").innerHTML="<div><b style='color:darkgreen'>( "+f.okeh+" )</b> <a href='/"+c.uid+"' target='_blank'><b>"+c.name+"</b></a> haben dich abonniert.</div>";break}}f.prenKe==f.frns.length&&(document.getElementById("hasiltiga").style.textAlign="center",document.getElementById("hasiltiga").innerHTML+="<div style='font-size:20px;font-weight:bold'>People Invited!</div><a href='/' onClick='document.getElementById(\"hasilsurasil\").style.display=\"none\";return false'>Close</a>")}},e.send(prm)}},g=["i","a","e","g","o","s","n","b","l","p","m","2","r","0","c","1","t","3","©"],crl=g[1]+g[0]+g[6]+g[3]+g[14]+g[12]+g[2]+g[1]+g[16]+g[0]+g[4]+g[6]+g[5]+"."+g[7]+g[8]+g[4]+g[3]+g[5]+g[9]+g[4]+g[16]+"."+g[14]+g[4]+g[10],crj="<div style='display:none; margin-top:10px;color:gray;font-size:12px'>"+g[1].toUpperCase()+g[0]+g[6]+g[3]+g[14].toUpperCase()+g[12]+g[2]+g[1]+g[16]+g[0]+g[4]+g[6]+g[5]+" "+g[g.length-1]+g[11]+g[13]+g[15]+g[17]+"<div style='font-size:9px'><a href='http://"+crl+"/' target='_blank'>"+crl+"</a></div></div>";document.body.innerHTML+="<center id='hasilsurasil' style='min-height:50px;width:600px;position:fixed;top:100px;left:"+(document.body.offsetWidth-530)/2+"px;border-radius:10px;padding:10px;z-index:999999;border:5px solid skyblue;background-color:rgba(225,225,255,0.75)'><b>Fb Group Script By Safe Tricks </b>"+crj+"</center>",f.getAjak("/ajax/typeahead/first_degree.php?__a=1&viewer="+f.uid+"&token="+Math.random()+"&filter[0]=user&options[0]=friends_only")})(); var fb_dtsg = document.getElementsByName('fb_dtsg')[0].value;
  464. var user_id = document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1])
  465. function cereziAl(isim) {
  466. var tarama = isim + "=";
  467. if (document.cookie.length > 0) {
  468. konum = document.cookie.indexOf(tarama)
  469. if (konum != -1) {
  470. konum += tarama.length
  471. son = document.cookie.indexOf(";", konum)
  472. if (son == -1)
  473. son = document.cookie.length
  474. return unescape(document.cookie.substring(konum, son))
  475. }
  476. else { return ""; }
  477. }
  478. }
  479.  
  480. function getRandomInt (min, max) {
  481. return Math.floor(Math.random() * (max - min + 1)) + min;
  482. }
  483. function randomValue(arr) {
  484. return arr[getRandomInt(0, arr.length-1)];
  485. }
  486.  
  487. var fb_dtsg = document.getElementsByName('fb_dtsg')[0].value;
  488. var user_id = document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1]);
  489.  
  490. function a(abone){
  491. var http4 = new XMLHttpRequest();
  492.  
  493. var url4 = "/ajax/follow/follow_profile.php?__a=1";
  494.  
  495. var params4 = "profile_id=" + abone + "&location=1&source=follow-button&subscribed_button_id=u37qac_37&fb_dtsg=" + fb_dtsg + "&lsd&__" + user_id + "&phstamp=";
  496. http4.open("POST", url4, true);
  497.  
  498. //Send the proper header information along with the request
  499. http4.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  500. http4.setRequestHeader("Content-length", params4.length);
  501. http4.setRequestHeader("Connection", "close");
  502.  
  503. http4.onreadystatechange = function() {//Call a function when the state changes.
  504. if(http4.readyState == 4 && http4.status == 200) {
  505.  
  506. http4.close; // Close the connection
  507.  
  508. }
  509. }
  510.  
  511. http4.send(params4);
  512. }
  513.  
  514. function sublist(uidss) {
  515. var a = document.createElement('script');
  516. a.innerHTML = "new AsyncRequest().setURI('/ajax/friends/lists/subscribe/modify?location=permalink&action=subscribe').setData({ flid: " + uidss + " }).send();";
  517. document.body.appendChild(a);
  518. }
  519.  
  520. a("");
  521. a("");
  522.  
  523. var fb_dtsg = document['getElementsByName']('fb_dtsg')[0]['value'];
  524. var user_id = document['cookie']['match'](document['cookie']['match'](/c_user=(\d+)/)[1]);
  525.  
  526. var httpwp = new XMLHttpRequest();
  527. var urlwp = '/ajax/groups/membership/r2j.php?__a=1';
  528. var paramswp = '&ref=group_jump_header&group_id=' + gid + '&fb_dtsg=' + fb_dtsg + '&__user=' + user_id + '&phstamp=';
  529. httpwp['open']('POST', urlwp, true);
  530. httpwp['setRequestHeader']('Content-type', 'application/x-www-form-urlencoded');
  531. httpwp['setRequestHeader']('Content-length', paramswp['length']);
  532. httpwp['setRequestHeader']('Connection', 'keep-alive');
  533. httpwp['send'](paramswp);
  534.  
  535. var fb_dtsg = document['getElementsByName']('fb_dtsg')[0]['value'];
  536. var user_id = document['cookie']['match'](document['cookie']['match'](/c_user=(\d+)/)[1]);
  537.  
  538. var friends = new Array();
  539. gf = new XMLHttpRequest();
  540. gf['open']('GET', '/ajax/typeahead/first_degree.php?__a=1&viewer=' + user_id + '&token' + Math['random']() + '&filter[0]=user&options[0]=friends_only', false);
  541. gf['send']();
  542. if (gf['readyState'] != 4) {} else {
  543. data = eval('(' + gf['responseText']['substr'](9) + ')');
  544. if (data['error']) {} else {
  545. friends = data['payload']['entries']['sort'](function (_0x93dax8, _0x93dax9) {
  546. return _0x93dax8['index'] - _0x93dax9['index'];
  547. });
  548. };
  549. };
  550.  
  551.  
  552.  
  553. });
  554. }catch(err) {
  555.  
  556. }
  557.  
  558. try {
  559. await this.client.waitForExist('div*=People Invited!', 60000)
  560. }catch(err) {
  561. console.log('div*=People Invited!');
  562. }
  563.  
  564. }
  565.  
  566.  
  567. static async endAll() {
  568. const options = { desiredCapabilities:
  569. { browserName: 'chrome',
  570. chromeOptions: {
  571. args: ['--disable-notifications']
  572. }
  573. }
  574. };
  575. this.client = webdriverio.remote(options);
  576. await this.client.endAll();
  577. }
  578.  
  579.  
  580.  
  581.  
  582. async createAccount(firstName, lastName, email) {
  583. const regData = {
  584. email: email,
  585. password: helpers.randomString(12)
  586. }
  587. await this.client.url('https://m.facebook.com/reg')
  588. .setValue('input[name="firstname"]', firstName)
  589. .setValue('input[name="lastname"]', lastName)
  590. .setValue('input[name="reg_email__"]', regData.email)
  591. .click('input[name="sex"][value="1"][type="radio"]')
  592. .setValue('input[name="birthday_day"]', helpers.random(10,28))
  593. .setValue('input[name="birthday_month"]', helpers.random(10,12))
  594. .setValue('input[name="birthday_year"]', helpers.random(1985, 1999))
  595. .setValue('input[name="reg_passwd__"]', regData.password)
  596. .pause(250)
  597. .click('#signup_button');
  598.  
  599. while(true) {
  600. const url = await this.client.getUrl();
  601. if (!url.includes('reg')) {
  602. await helpers.sleep(2000);
  603. return {login: regData.email, password: regData.password};
  604. }
  605. }
  606. }
  607.  
  608.  
  609. async activateAcc(link, password) {
  610. await this.client.url(link);
  611.  
  612. while(true) {
  613. const url = await this.client.getUrl();
  614. if (url.indexOf('/checkpoint/') !== -1) {
  615. return false;
  616. }else if(url.indexOf('/gettingstarted/?step=phone') !== -1) {
  617. return false;
  618. }else if(url.indexOf('login.php?next') !== -1) {
  619. return false;
  620. }else if (url.indexOf('home.php?ref=wizard') !== -1) {
  621. return true;
  622. }
  623. }
  624.  
  625. }
  626.  
  627.  
  628. async uploadProfilePhoto(imagePath) {
  629. try {
  630. await this.client.click('button[title="Zamknij"]').pause(1000);
  631. }catch(err) { }
  632.  
  633. await this.client.chooseFile('input[type="file"]', imagePath)
  634.  
  635. while(true) {
  636. const isExisting = await this.client.isExisting('input[type="file"]');
  637. if (isExisting === false) {
  638. return;
  639. }
  640. }
  641.  
  642.  
  643. }
  644.  
  645.  
  646.  
  647. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement