SN-Koarashi / ig-helper

In Instagram, downloading is possible for both photos and videos from posts, as well as for stories, reels or profile picture.
GNU General Public License v3.0
41 stars 3 forks source link

Unify more things between stories and highlights #40

Closed sn-o-w closed 2 weeks ago

sn-o-w commented 3 weeks ago

@SN-Koarashi What am I missing?

It will work if you switch from a highlights section to another highlights section, but if you scroll highlights inside same section, you won't see "isHighlightsStory" triggering in console between them. 🤔

SN-Koarashi commented 3 weeks ago

Because the URL does not update when switching within the same section, "isHighlightStory" will only be called once. In summary, your approach will cause the video thumbnail detection function to fail. @sn-o-w

sn-o-w commented 3 weeks ago

Because the URL does not update when switching within the same section, "isHighlightStory" will only be called once. In summary, your approach will cause the video thumbnail detection function to fail. @sn-o-w

Can't we use "scroll" event listener for this instead of relying on URL? I mean for both stories and highlights? 🤔

Basically, to use "scroll" event listener as long as the adress bar contains "/stories/" and/or "/highlights/". 🤔

SN-Koarashi commented 3 weeks ago

Do you have code samples?

sn-o-w commented 3 weeks ago

Do you have code samples?

Nope. The thing related to "scroll" event listener was just a plain idea. 🤔

SN-Koarashi commented 3 weeks ago

I didn't find a listener for the scroll event in DevTools, so I don't think the scroll event is triggered when switching stories or highlights

sn-o-w commented 3 weeks ago

I didn't find a listener for the scroll event in DevTools, so I don't think the scroll event is triggered when switching stories or highlights

Can't we use "load" and "loadedmetadata" event listeners as long as the adress bar contains "/stories/" and/or "/highlights/"? "load" is used for photos and "loadedmetadata" for videos. They are triggered always for stories and highlights, is either "load" or "loadedmetadata". 🤔

This would lead to a more correct behaviour instead of relying on manual timers.

SN-Koarashi commented 2 weeks ago

But they are dynamically inserted DOM elements, so you still need to manually add listeners through timers such as setTimeout. In fact, there is no fundamental difference from the current implementation method.

sn-o-w commented 2 weeks ago

But they are dynamically inserted DOM elements, so you still need to manually add listeners through timers such as setTimeout. In fact, there is no fundamental difference from the current implementation method.

The thing is, sometimes thumbnail button is still missing. Relying on these event listeners could make a positive impact.

SN-Koarashi commented 2 weeks ago

In fact, thumbnails already have event listeners, right?

sn-o-w commented 2 weeks ago

In fact, thumbnails already have event listeners, right?

Recently, we worked on something related to stories and highlights that involved event listeners, which were originally meant to remove buttons but not for adding the buttons. 🤔

SN-Koarashi commented 2 weeks ago

That's right, but I'm referring to the timeupdate event listener added earlier.

SN-Koarashi commented 2 weeks ago

But maybe we can start with the audio observer that I just updated. Wait for me.

SN-Koarashi commented 2 weeks ago

I changed it to check whether the thumbnail is inserted through the audio observer. You can see if there are any related issue with this way of writing. @sn-o-w

sn-o-w commented 2 weeks ago

@SN-Koarashi Should I check the latest commits or the commits in this PR? 🤔

SN-Koarashi commented 2 weeks ago

the comments in this PR

sn-o-w commented 2 weeks ago

So I just updated the script inside Violentmonkey and I need more time to test it.

One thing I saw a few secs ago:

Screenshot_45

I've switched from a highlight section to another highlight section and this happened.

For some reason, only thumbnail button spawned. 🤣

sn-o-w commented 2 weeks ago

@SN-Koarashi Since thumbnail button inside highlights/stories relies now on event listener, the regular buttons (download & preview) don't rely on event listener.

As I said, it looks like event listeners like 'timeupdate' does indeed seem to lead to more accurate timing. 🤔

SN-Koarashi commented 2 weeks ago

The main thing is to insert the event listener through the observer, which ensures that the event is inserted after the DOM is generated.

SN-Koarashi commented 2 weeks ago

But judging from the thumbnail, at least it works well and can be merged, right?

sn-o-w commented 2 weeks ago

But judging from the thumbnail, at least it works well and can be merged, right?

So far, it doesn't seem to cause any harm. 🤔