@@ -23,7 +23,7 @@ export class InstagramPostsBehavior {
23
23
static id = "Instagram" ;
24
24
25
25
static isMatch ( ) {
26
- return ! ! window . location . href . match ( / h t t p s : \/ \/ ( w w w \. ) ? i n s t a g r a m \. c o m \/ \w [ \w . - ] + / ) ;
26
+ return ! ! window . location . href . match ( / h t t p s : \/ \/ ( w w w \. ) ? i n s t a g r a m \. c o m \/ / ) ;
27
27
}
28
28
29
29
static init ( ) {
@@ -204,14 +204,7 @@ export class InstagramPostsBehavior {
204
204
205
205
await fetch ( window . location . href ) ;
206
206
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 ) ;
215
208
216
209
next = xpathNode ( Q . nextPost ) ;
217
210
@@ -223,7 +216,25 @@ export class InstagramPostsBehavior {
223
216
await sleep ( waitUnit * 5 ) ;
224
217
}
225
218
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
+
226
232
async * run ( ctx ) {
233
+ if ( window . location . pathname . startsWith ( "/p/" ) ) {
234
+ yield * this . handleSinglePost ( ctx ) ;
235
+ return ;
236
+ }
237
+
227
238
const { getState, scrollIntoView, sleep, waitUnit, xpathNode } = ctx . Lib ;
228
239
//const origLoc = window.location.href;
229
240
0 commit comments