Skip to content

Commit 61438a9

Browse files
committed
Merge branch 'main' into autoscroll-standalone-behavior
2 parents a482e98 + aee78a4 commit 61438a9

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-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/autoscroll.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class AutoScroll {
1010
samePosCount: number;
1111

1212
origPath: string;
13+
lastMsg = "";
1314

1415
constructor() {
1516
//super();
@@ -47,6 +48,14 @@ export class AutoScroll {
4748
return this.currScrollPos() < Math.max(scrollElem.clientHeight, scrollElem.scrollHeight);
4849
}
4950

51+
debug(msg: string) {
52+
if (this.lastMsg === msg) {
53+
return;
54+
}
55+
super.debug(msg);
56+
this.lastMsg = msg;
57+
}
58+
5059
hasScrollEL(obj) {
5160
try {
5261
return !!self["getEventListeners"](obj).scroll;

src/site/instagram.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class InstagramFeedBehavior {
2525
static id = "Instagram";
2626

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

3131
static init() {
@@ -206,14 +206,7 @@ export class InstagramFeedBehavior {
206206

207207
await fetch(window.location.href);
208208

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

218211
next = xpathNode(Q.nextPost);
219212

@@ -225,7 +218,25 @@ export class InstagramFeedBehavior {
225218
await sleep(waitUnit * 5);
226219
}
227220

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

0 commit comments

Comments
 (0)