How to re-render content script on URL change (youtube)
I'm building a Plasmo extension for YouTube - youtube updates their pages dynamically, so the content script is not being re-run when page content is changed. So for example, I want to re-run a Plasmo CSUI each time the user goes to a different video.
I imagine I'd have to detect change in the DOM tree somehow, and then trigger my content script to re-run. However, my question is, how would I go about triggering a content script to rerun in Plasmo?
4 Replies
You can use either a watchOverlayAnchor or issue your own custom mutation observer - based on prior experience with youtube, I've found that you just need to check for the right element to mount and the existing mutationObserver should just work - i.e whatever you return via the anchor getters
can you please comeup with more details?
im really stuck with this,
i want to render my html on youtube videos,
but it does not work when i click videos from youtube it self, i will have to refresh once so content.tsx knows that url changed
Easiest is to use the watchOverlay function, but there're other ways of doing it. Do you want to spearhead a youtube specific extension divisionf for the plasmo framework? #youtube
i wanted to use watchOverlay function, but I don't understand how to use it properly in this case,
yes i am.