instauto 9.2.0 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/src/index.js +19 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instauto",
|
|
3
|
-
"version": "9.2.
|
|
3
|
+
"version": "9.2.1",
|
|
4
4
|
"description": "Instagram automation library written in Node.js",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"eslint": "^7.32.0 || ^8.2.0",
|
|
26
|
-
"eslint-config-airbnb": "^16.1.0",
|
|
27
26
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
28
27
|
"eslint-plugin-import": "^2.25.2",
|
|
29
28
|
"puppeteer": "^1.19.0"
|
package/src/index.js
CHANGED
|
@@ -129,11 +129,13 @@ const Instauto = async (db, browser, options) => {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
const sleepFixed = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
133
|
+
|
|
132
134
|
const sleep = (ms, deviation = 1) => {
|
|
133
135
|
let msWithDev = ((Math.random() * deviation) + 1) * ms;
|
|
134
136
|
if (dryRun) msWithDev = Math.min(3000, msWithDev); // for dryRun, no need to wait so long
|
|
135
137
|
logger.log('Waiting', (msWithDev / 1000).toFixed(2), 'sec');
|
|
136
|
-
return
|
|
138
|
+
return sleepFixed(msWithDev);
|
|
137
139
|
};
|
|
138
140
|
|
|
139
141
|
async function onImageLiked({ username, href }) {
|
|
@@ -413,7 +415,11 @@ const Instauto = async (db, browser, options) => {
|
|
|
413
415
|
}
|
|
414
416
|
|
|
415
417
|
async function findUnfollowConfirmButton() {
|
|
416
|
-
|
|
418
|
+
let elementHandles = await page.$x("//button[text()='Unfollow']");
|
|
419
|
+
if (elementHandles.length > 0) return elementHandles[0];
|
|
420
|
+
|
|
421
|
+
// https://github.com/mifi/SimpleInstaBot/issues/191
|
|
422
|
+
elementHandles = await page.$x("//*[@role='button'][contains(.,'Unfollow')]");
|
|
417
423
|
return elementHandles[0];
|
|
418
424
|
}
|
|
419
425
|
|
|
@@ -722,17 +728,17 @@ const Instauto = async (db, browser, options) => {
|
|
|
722
728
|
return false;
|
|
723
729
|
}
|
|
724
730
|
if (
|
|
725
|
-
(followUserMaxFollowers != null && followedByCount > followUserMaxFollowers)
|
|
726
|
-
(followUserMaxFollowing != null && followsCount > followUserMaxFollowing)
|
|
727
|
-
(followUserMinFollowers != null && followedByCount < followUserMinFollowers)
|
|
728
|
-
(followUserMinFollowing != null && followsCount < followUserMinFollowing)
|
|
731
|
+
(followUserMaxFollowers != null && followedByCount > followUserMaxFollowers)
|
|
732
|
+
|| (followUserMaxFollowing != null && followsCount > followUserMaxFollowing)
|
|
733
|
+
|| (followUserMinFollowers != null && followedByCount < followUserMinFollowers)
|
|
734
|
+
|| (followUserMinFollowing != null && followsCount < followUserMinFollowing)
|
|
729
735
|
) {
|
|
730
736
|
logger.log('User has too many or too few followers or following, skipping.', 'followedByCount:', followedByCount, 'followsCount:', followsCount);
|
|
731
737
|
return false;
|
|
732
738
|
}
|
|
733
739
|
if (
|
|
734
|
-
(followUserRatioMax != null && ratio > followUserRatioMax)
|
|
735
|
-
(followUserRatioMin != null && ratio < followUserRatioMin)
|
|
740
|
+
(followUserRatioMax != null && ratio > followUserRatioMax)
|
|
741
|
+
|| (followUserRatioMin != null && ratio < followUserRatioMin)
|
|
736
742
|
) {
|
|
737
743
|
logger.log('User has too many followers compared to follows or opposite, skipping');
|
|
738
744
|
return false;
|
|
@@ -1034,7 +1040,7 @@ const Instauto = async (db, browser, options) => {
|
|
|
1034
1040
|
await sleep(6000);
|
|
1035
1041
|
}
|
|
1036
1042
|
|
|
1037
|
-
await
|
|
1043
|
+
await sleepFixed(10000);
|
|
1038
1044
|
|
|
1039
1045
|
// Sometimes login button gets stuck with a spinner
|
|
1040
1046
|
// https://github.com/mifi/SimpleInstaBot/issues/25
|
|
@@ -1168,9 +1174,9 @@ const Instauto = async (db, browser, options) => {
|
|
|
1168
1174
|
});
|
|
1169
1175
|
|
|
1170
1176
|
function condition(username) {
|
|
1171
|
-
return getPrevFollowedUser(username)
|
|
1172
|
-
!excludeUsers.includes(username)
|
|
1173
|
-
(new Date().getTime() - getPrevFollowedUser(username).time) / (1000 * 60 * 60 * 24) > ageInDays;
|
|
1177
|
+
return getPrevFollowedUser(username)
|
|
1178
|
+
&& !excludeUsers.includes(username)
|
|
1179
|
+
&& (new Date().getTime() - getPrevFollowedUser(username).time) / (1000 * 60 * 60 * 24) > ageInDays;
|
|
1174
1180
|
}
|
|
1175
1181
|
|
|
1176
1182
|
return safelyUnfollowUserList(followingUsersGenerator, limit, condition);
|
|
@@ -1182,8 +1188,7 @@ const Instauto = async (db, browser, options) => {
|
|
|
1182
1188
|
getFollowers: false,
|
|
1183
1189
|
});
|
|
1184
1190
|
|
|
1185
|
-
return allFollowing.filter(u =>
|
|
1186
|
-
!getPrevFollowedUser(u) && !excludeUsers.includes(u));
|
|
1191
|
+
return allFollowing.filter(u => !getPrevFollowedUser(u) && !excludeUsers.includes(u));
|
|
1187
1192
|
}
|
|
1188
1193
|
|
|
1189
1194
|
return {
|