Skip to content

Commit

Permalink
Merge pull request #18 from lavaswimmer/master
Browse files Browse the repository at this point in the history
Fixed error Follow button not found
  • Loading branch information
mifi authored Feb 29, 2020
2 parents 7fa1399 + 25851c3 commit cd93b34
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ module.exports = async (browser, options) => {

function hasReachedFollowedUserRateLimit() {
return getNumFollowedUsersThisTimeUnit(60 * 60 * 1000) >= maxFollowsPerHour
|| getNumFollowedUsersThisTimeUnit(24 * 60 * 60 * 1000) >= maxFollowsPerDay;
|| getNumFollowedUsersThisTimeUnit(24 * 60 * 60 * 1000) >= maxFollowsPerDay;
}

function haveRecentlyFollowedUser(username) {
Expand Down Expand Up @@ -154,10 +154,10 @@ module.exports = async (browser, options) => {

async function findFollowButton() {
const elementHandles = await page.$x(`//header//button[text()='Follow']`);
if (elementHandles.length > 0) elementHandles[0];
if (elementHandles.length > 0) return elementHandles[0];

const elementHandles2 = await page.$x(`//header//button[text()='Follow Back']`);
if (elementHandles2.length > 0) elementHandles[0];
if (elementHandles2.length > 0) return elementHandles[0];
}

async function findUnfollowButton() {
Expand Down Expand Up @@ -533,7 +533,7 @@ module.exports = async (browser, options) => {
if (!(await isLoggedIn())) {
assert(myUsername);
assert(password);

await page.click('a[href="/accounts/login/?source=auth_switcher"]');
await sleep(1000);
await page.type('input[name="username"]', myUsername, { delay: 50 });
Expand Down

0 comments on commit cd93b34

Please sign in to comment.