You are browsing as a guest. Sign up (or log in) to start making projects!

Open comments for this post

48m 37s logged

For the last hour or so I had realized a big problem with the current implementation, which is that the Stardance app uses Turbo, which apparently in this case acts like a SPA (Single page application). Truth be told, I had to make more use of AI here than I usually would (however I did not copy paste code or add anything which I didn’t first check or understand) as I have not been personally faced with this problem before, however I was aware of this challenge from previous projects or blogs read. The problem was that if I just kept creating a new loop on every navigation to circumvent this, old loops would end up never finishing and would just keep waiting for new posts to load (which never happened), inevitably leading to a memory leak eventually. The fix ended up being using document.documentElement instead of document.body for the mutation because (according to GPT, however I will write a comment in case I come across any documentation) Turbo will replace stuff of the body inside of the whole HTML of the page (so, to ), which triggers a mutation when watching documentElement, however if we watch document.body, and Turbo replaces that all together, MutationObserver stays attached to the old, now removed, node, which means we are basically watching a dead node for new posts (again, take this with a grain of salt). This means I could also scrap the waitForElm function and shorten the code. There are likely many better ways to do this (which are welcome in the comments), but for someone who is still a beginner in extension and web development overall, I am just happy that it works and that AI helped me discover something new that I think is a challenge for many extensions that operate on modern web applications such as Youtube, X etc. Now free of bugs, I will continue working on the UI.

0
11

Comments 1

@tudor

In retrospect, I was also kind of over complicating the way I was watching for new posts.