@@ -23,7 +23,7 @@ export class InstagramPostsBehavior {
2323 static id = "Instagram" ;
2424
2525 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 \/ / ) ;
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