instauto 9.1.6 → 9.1.9
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/README.md +2 -0
- package/package.json +1 -1
- package/src/index.js +34 -15
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
+
[](https://discord.gg/Rh3KT9zyhj) [](https://paypal.me/mifino/usd)
|
|
4
|
+
|
|
3
5
|
instauto is an Instagram automation/bot library written in modern, clean javascript using Google's Puppeteer. Goal is to be very easy to set up, use, and extend, and obey instagram's limits. Heavily inspired by [InstaPy](https://github.com/timgrossmann/InstaPy), but I thought it was way too heavy and hard to setup.
|
|
4
6
|
|
|
5
7
|
**NEW! 🎉**
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -170,11 +170,14 @@ const Instauto = async (db, browser, options) => {
|
|
|
170
170
|
return new Date().getTime() - followedUserEntry.time < dontUnfollowUntilTimeElapsed;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
// See https://github.com/mifi/SimpleInstaBot/issues/140#issuecomment-1149105387
|
|
174
|
+
const gotoUrl = async (url) => page.goto(url, { waitUntil: ['load', 'domcontentloaded', 'networkidle0'] });
|
|
175
|
+
|
|
173
176
|
async function gotoWithRetry(url) {
|
|
174
177
|
const maxAttempts = 3;
|
|
175
178
|
for (let attempt = 0; ; attempt += 1) {
|
|
176
179
|
logger.log(`Goto ${url}`);
|
|
177
|
-
const response = await
|
|
180
|
+
const response = await gotoUrl(url);
|
|
178
181
|
await sleep(2000);
|
|
179
182
|
const status = response.status();
|
|
180
183
|
|
|
@@ -312,17 +315,23 @@ const Instauto = async (db, browser, options) => {
|
|
|
312
315
|
}
|
|
313
316
|
|
|
314
317
|
async function findUnfollowButton() {
|
|
315
|
-
|
|
318
|
+
let button = await findButtonWithText('Following');
|
|
319
|
+
if (button) return button;
|
|
320
|
+
|
|
321
|
+
button = await findButtonWithText('Requested');
|
|
322
|
+
if (button) return button;
|
|
323
|
+
|
|
324
|
+
let elementHandles = await page.$x("//header//button[*//span[@aria-label='Following']]");
|
|
316
325
|
if (elementHandles.length > 0) return elementHandles[0];
|
|
317
326
|
|
|
318
|
-
|
|
319
|
-
if (
|
|
327
|
+
elementHandles = await page.$x("//header//button[*//span[@aria-label='Requested']]");
|
|
328
|
+
if (elementHandles.length > 0) return elementHandles[0];
|
|
320
329
|
|
|
321
|
-
|
|
322
|
-
if (
|
|
330
|
+
elementHandles = await page.$x("//header//button[*//*[name()='svg'][@aria-label='Following']]");
|
|
331
|
+
if (elementHandles.length > 0) return elementHandles[0];
|
|
323
332
|
|
|
324
|
-
|
|
325
|
-
if (
|
|
333
|
+
elementHandles = await page.$x("//header//button[*//*[name()='svg'][@aria-label='Requested']]");
|
|
334
|
+
if (elementHandles.length > 0) return elementHandles[0];
|
|
326
335
|
|
|
327
336
|
return undefined;
|
|
328
337
|
}
|
|
@@ -795,7 +804,7 @@ const Instauto = async (db, browser, options) => {
|
|
|
795
804
|
|
|
796
805
|
if (enableCookies) await tryLoadCookies();
|
|
797
806
|
|
|
798
|
-
const goHome = async () =>
|
|
807
|
+
const goHome = async () => gotoUrl(`${instagramBaseUrl}/?hl=en`);
|
|
799
808
|
|
|
800
809
|
// https://github.com/mifi/SimpleInstaBot/issues/28
|
|
801
810
|
async function setLang(short, long, assumeLoggedIn = false) {
|
|
@@ -807,7 +816,7 @@ const Instauto = async (db, browser, options) => {
|
|
|
807
816
|
// when logged in, we need to go to account in order to be able to check/set language
|
|
808
817
|
// (need to see the footer)
|
|
809
818
|
if (assumeLoggedIn) {
|
|
810
|
-
await
|
|
819
|
+
await gotoUrl(`${instagramBaseUrl}/accounts/edit/`);
|
|
811
820
|
} else {
|
|
812
821
|
await goHome();
|
|
813
822
|
}
|
|
@@ -872,6 +881,19 @@ const Instauto = async (db, browser, options) => {
|
|
|
872
881
|
}
|
|
873
882
|
}
|
|
874
883
|
|
|
884
|
+
async function tryClickLogin() {
|
|
885
|
+
async function tryClickButton(xpath) {
|
|
886
|
+
const btn = (await page.$x(xpath))[0];
|
|
887
|
+
if (!btn) return false;
|
|
888
|
+
await btn.click();
|
|
889
|
+
return true;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
if (await tryClickButton("//button[.//text() = 'Log In']")) return true;
|
|
893
|
+
if (await tryClickButton("//button[.//text() = 'Log in']")) return true; // https://github.com/mifi/instauto/pull/110 https://github.com/mifi/instauto/issues/109
|
|
894
|
+
return false;
|
|
895
|
+
}
|
|
896
|
+
|
|
875
897
|
await setEnglishLang(false);
|
|
876
898
|
|
|
877
899
|
await tryPressButton(await page.$x('//button[contains(text(), "Accept")]'), 'Accept cookies dialog');
|
|
@@ -900,11 +922,8 @@ const Instauto = async (db, browser, options) => {
|
|
|
900
922
|
await sleep(1000);
|
|
901
923
|
|
|
902
924
|
for (;;) {
|
|
903
|
-
const
|
|
904
|
-
if (
|
|
905
|
-
await loginButton.click();
|
|
906
|
-
break;
|
|
907
|
-
}
|
|
925
|
+
const didClickLogin = await tryClickLogin();
|
|
926
|
+
if (didClickLogin) break;
|
|
908
927
|
logger.warn('Login button not found. Maybe you can help me click it? And also report an issue on github with a screenshot of what you\'re seeing :)');
|
|
909
928
|
await sleep(6000);
|
|
910
929
|
}
|