forked from mifi/instauto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
89 lines (67 loc) · 3.15 KB
/
Copy pathexample.js
File metadata and controls
89 lines (67 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
const puppeteer = require('puppeteer'); // eslint-disable-line import/no-extraneous-dependencies
const Instauto = require('instauto'); // eslint-disable-line import/no-unresolved
const options = {
cookiesPath: './cookies.json',
username: 'your-ig-username',
password: 'your-ig-password',
// Global limit that prevents follow or unfollows (total) to exceed this number over a sliding window of one hour:
maxFollowsPerHour: 20,
// Global limit that prevents follow or unfollows (total) to exceed this number over a sliding window of one day:
maxFollowsPerDay: 150,
// (NOTE setting the above parameters too high will cause temp ban/throttle)
maxLikesPerDay: 50,
// Don't follow users that have a followers / following ratio less than this:
followUserRatioMin: 0.2,
// Don't follow users that have a followers / following ratio higher than this:
followUserRatioMax: 4.0,
// Don't follow users who have more followers than this:
followUserMaxFollowers: null,
// Don't follow users who have more people following them than this:
followUserMaxFollowing: null,
// Don't follow users who have less followers than this:
followUserMinFollowers: null,
// Don't follow users who have more people following them than this:
followUserMinFollowing: null,
dontUnfollowUntilTimeElapsed: 3 * 24 * 60 * 60 * 1000,
// Usernames that we should not touch, e.g. your friends and actual followings
excludeUsers: [],
// If true, will not do any actions (defaults to true)
dryRun: false,
};
(async () => {
let browser;
try {
browser = await puppeteer.launch({ headless: false });
// Create a database where state will be loaded/saved to
const instautoDb = await Instauto.JSONDB({
// Will store a list of all users that have been followed before, to prevent future re-following.
followedDbPath: './followed.json',
// Will store all unfollowed users here
unfollowedDbPath: './unfollowed.json',
// Will store all likes here
likedPhotosDbPath: './liked-photos.json',
});
const instauto = await Instauto(instautoDb, browser, options);
// List of usernames that we should follow the followers of, can be celebrities etc.
const usersToFollowFollowersOf = ['lostleblanc', 'sam_kolder'];
// Now go through each of these and follow a certain amount of their followers
await instauto.followUsersFollowers({ usersToFollowFollowersOf, skipPrivate: true, enableLikeImages: true });
await instauto.sleep(10 * 60 * 1000);
// This is used to unfollow people - auto-followed AND manually followed -
// who are not following us back, after some time has passed
// (config parameter dontUnfollowUntilTimeElapsed)
await instauto.unfollowNonMutualFollowers();
await instauto.sleep(10 * 60 * 1000);
// Unfollow auto-followed users (regardless of whether they are following us)
// after a certain amount of days
await instauto.unfollowOldFollowed({ ageInDays: 60 });
console.log('Done running');
await instauto.sleep(30000);
} catch (err) {
console.error(err);
} finally {
console.log('Closing browser');
if (browser) await browser.close();
}
})();