Skip to content

Commit 8913ecd

Browse files
authored
instagram: also handle single post in same behavior, just iterate through slideshow + comments (#103)
bump to 0.9.2
1 parent a8bcfe1 commit 8913ecd

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "browsertrix-behaviors",
3-
"version": "0.9.1",
3+
"version": "0.9.2",
44
"main": "index.js",
55
"author": "Webrecorder Software",
66
"license": "AGPL-3.0-or-later",

src/site/instagram.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class InstagramPostsBehavior {
2323
static id = "Instagram";
2424

2525
static isMatch() {
26-
return !!window.location.href.match(/https:\/\/(www\.)?instagram\.com\/\w[\w.-]+/);
26+
return !!window.location.href.match(/https:\/\/(www\.)?instagram\.com\//);
2727
}
2828

2929
static init() {
@@ -204,14 +204,7 @@ export class InstagramPostsBehavior {
204204

205205
await fetch(window.location.href);
206206

207-
yield* this.iterSubposts(ctx);
208-
209-
yield getState(ctx, "Loaded Comments", "comments");
210-
211-
await Promise.race([
212-
this.iterComments(ctx),
213-
sleep(this.maxCommentsTime)
214-
]);
207+
yield* this.handleSinglePost(ctx);
215208

216209
next = xpathNode(Q.nextPost);
217210

@@ -223,7 +216,25 @@ export class InstagramPostsBehavior {
223216
await sleep(waitUnit * 5);
224217
}
225218

219+
async* handleSinglePost(ctx) {
220+
const { getState, sleep } = ctx.Lib;
221+
222+
yield* this.iterSubposts(ctx);
223+
224+
yield getState(ctx, "Loaded Comments", "comments");
225+
226+
await Promise.race([
227+
this.iterComments(ctx),
228+
sleep(this.maxCommentsTime)
229+
]);
230+
}
231+
226232
async* run(ctx) {
233+
if (window.location.pathname.startsWith("/p/")) {
234+
yield* this.handleSinglePost(ctx);
235+
return;
236+
}
237+
227238
const { getState, scrollIntoView, sleep, waitUnit, xpathNode } = ctx.Lib;
228239
//const origLoc = window.location.href;
229240

0 commit comments

Comments
 (0)