instauto 9.1.10 → 9.2.0
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 -1
- package/src/index.js +37 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -55,6 +55,7 @@ const Instauto = async (db, browser, options) => {
|
|
|
55
55
|
followUserMinFollowing = null,
|
|
56
56
|
|
|
57
57
|
shouldFollowUser = null,
|
|
58
|
+
shouldLikeMedia = null,
|
|
58
59
|
|
|
59
60
|
dontUnfollowUntilTimeElapsed = 3 * 24 * 60 * 60 * 1000,
|
|
60
61
|
|
|
@@ -279,7 +280,7 @@ const Instauto = async (db, browser, options) => {
|
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
282
|
} catch (err) {
|
|
282
|
-
logger.warn(
|
|
283
|
+
logger.warn(`Unable to get user data from page (${err.name}) - This is normal`);
|
|
283
284
|
}
|
|
284
285
|
return undefined;
|
|
285
286
|
}
|
|
@@ -570,7 +571,7 @@ const Instauto = async (db, browser, options) => {
|
|
|
570
571
|
}
|
|
571
572
|
|
|
572
573
|
/* eslint-disable no-undef */
|
|
573
|
-
async function likeCurrentUserImagesPageCode({ dryRun: dryRunIn, likeImagesMin, likeImagesMax }) {
|
|
574
|
+
async function likeCurrentUserImagesPageCode({ dryRun: dryRunIn, likeImagesMin, likeImagesMax, shouldLikeMedia: shouldLikeMediaIn }) {
|
|
574
575
|
const allImages = Array.from(document.getElementsByTagName('a')).filter(el => /instagram.com\/p\//.test(el.href));
|
|
575
576
|
|
|
576
577
|
// eslint-disable-next-line no-shadow
|
|
@@ -629,12 +630,42 @@ const Instauto = async (db, browser, options) => {
|
|
|
629
630
|
|
|
630
631
|
if (!foundClickable) throw new Error('Like button not found');
|
|
631
632
|
|
|
632
|
-
|
|
633
|
-
foundClickable.click();
|
|
633
|
+
const instautoLog2 = instautoLog;
|
|
634
634
|
|
|
635
|
+
// eslint-disable-next-line no-inner-declarations
|
|
636
|
+
function likeImage() {
|
|
637
|
+
if (shouldLikeMediaIn !== null && (typeof shouldLikeMediaIn === 'function')) {
|
|
638
|
+
const presentation = dialog.querySelector('article[role=presentation]');
|
|
639
|
+
const img = presentation.querySelector('img[alt^="Photo by "]');
|
|
640
|
+
const video = presentation.querySelector('video[type="video/mp4"]');
|
|
641
|
+
const mediaDesc = presentation.querySelector('[role=menuitem] h2 ~ div').textContent;
|
|
642
|
+
let mediaType; let src; let alt; let poster;
|
|
643
|
+
if (img) {
|
|
644
|
+
mediaType = 'image';
|
|
645
|
+
({ src } = img);
|
|
646
|
+
({ alt } = img);
|
|
647
|
+
} else if (video) {
|
|
648
|
+
mediaType = 'video';
|
|
649
|
+
({ poster } = video);
|
|
650
|
+
({ src } = video);
|
|
651
|
+
} else {
|
|
652
|
+
instautoLog2('Could not determin mediaType');
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if (!shouldLikeMediaIn({ mediaType, mediaDesc, src, alt, poster })) {
|
|
656
|
+
instautoLog2(`shouldLikeMedia returned false for ${image.href}, skipping`);
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
foundClickable.click();
|
|
635
662
|
window.instautoOnImageLiked(image.href);
|
|
636
663
|
}
|
|
637
664
|
|
|
665
|
+
if (!dryRunIn) {
|
|
666
|
+
likeImage();
|
|
667
|
+
}
|
|
668
|
+
|
|
638
669
|
await window.instautoSleep(3000);
|
|
639
670
|
|
|
640
671
|
const closeButtonChild = document.querySelector('svg[aria-label="Close"]');
|
|
@@ -669,7 +700,7 @@ const Instauto = async (db, browser, options) => {
|
|
|
669
700
|
// Ignore already exists error
|
|
670
701
|
}
|
|
671
702
|
|
|
672
|
-
await page.evaluate(likeCurrentUserImagesPageCode, { dryRun, likeImagesMin, likeImagesMax });
|
|
703
|
+
await page.evaluate(likeCurrentUserImagesPageCode, { dryRun, likeImagesMin, likeImagesMax, shouldLikeMedia });
|
|
673
704
|
}
|
|
674
705
|
|
|
675
706
|
async function followUserRespectingRestrictions({ username, skipPrivate = false }) {
|
|
@@ -1172,6 +1203,7 @@ const Instauto = async (db, browser, options) => {
|
|
|
1172
1203
|
getPage,
|
|
1173
1204
|
followUsersFollowers: processUsersFollowers,
|
|
1174
1205
|
doesUserFollowMe,
|
|
1206
|
+
navigateToUserAndGetData,
|
|
1175
1207
|
};
|
|
1176
1208
|
};
|
|
1177
1209
|
|