-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: should now inject interaction buttons properly on post detail page #87
Conversation
Okay, tested it practically (ref):
If the injection should be a problem and makes it less (sporadically) buggy, I BTW, would be fine for introducing the "Acess all sites" permissions (note just to explain the permission in the permission.md document then). Mastodon v4.0.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I am unsure what the problem here is… but I have some tips anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed a comment
Co-authored-by: rugk <[email protected]>
Co-authored-by: rugk <[email protected]>
Thanks for the detailed writeup! Yes, now I can reproduce it. The problem is with the injection. It seems that when you navigate to a different page on a PWA |
Figured it out. So it appears that Firefox will wait for the Return Value of the content_script to resolve before re-running the content_script on the same tab, unless the tab reloads. The return value of the
@rugk, trouble you to test it again and confirm the issue has been resolved. |
Please also note we have a manual testing guide, so if you could test it manually based on that guide, that would be helpful, too: https://github.com/rugk/mastodon-simplified-federation/wiki/Testing Please note the guide is partially outdated, feel free to correct that… see #45. |
forget this partI managed to find a problem: If I use the link from the guide here and quickly click on any interaction button/star, while the progress bar at the top is still loading, I get the same issue again, it's still the old dialog. I assume the content script is only injected/we trigger only when the page has fully loaded? Or actually the MutationObserver can trigger earlier, can't it? Addendum: Managed to reproduce this twice and I guess it was because I was fast hmm... maybe one also needs to load a toot that is not yet cached in your browser and poztentially large (image or so). Okay, tried to reproduce it again via network throtteling, I cannot: https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/throttling/index.html As soon as the star is there I click on it and here it goes… though hmm, maybe of course network throtteling does only throttle the network not JS… 🙃 Ahhh, I did not update my testing code I am sorrry… Back testing 8490dbeSo with throtteling in 2G good/3G scenarious (may not be relevant) I noticed when I click on a toot at the top right (the date) to open it and then click any of the interaction buttons, it does not work either. Also scrolling down and loading new stuff via AJAX works. It reproducibly fails to inject the stuff when I navigate from account overview to a single toot. Navigation via browser back/forwards buttons yields in the same result. |
Ahh, yeah… that is a good thing you noticed! However, your solution of removing the Actually, do we really want to inject the content script multiple times? I think, actually, wo don't! It has all things to stay there and keep reacting on things that happen, AFAIK. So, instead, could not we maybe check for a "if isDeclared(SOME_CONSTANT_THAT_SHIOWS_WE_INJECTED_THIS_SCRIPT)" and then break processing, so nothing gets reinjected? (This is pseudo code of course.) Related problems (not looked into details): https://stackoverflow.com/questions/74624848/inject-content-script-only-once-in-a-webpage and https://discourse.mozilla.org/t/why-is-it-soo-hard-to-inject-a-content-script-only-once-at-site-load/38903 (ouch, I just saw that last one was from past self here, actually 🙈 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ see my comment above, reinjection complicates stuff and may cause weird side-effects indeed, so let's prevent that from happening.
It seems to be difficult to re-run the injection functions when the Mastodon uses the History API to navigate (e.g. from toot detail to profile page) because Firefox does not emit a Instead, I have used a new MutationObserver to check for new UI elements. I have removed the previous MutationObserver and have carefully tailored the CSS selector for the new one, so I think the overhead of monitoring UI changes should be reasonable. I have tried various more specific CSS selectors, but besides the risk of breaking changes if Mastodon changes its UI, the element selected may also be replaced by some actions (e.g. the main column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise LGTM, let me test.
BTW while testing I had #88, but now seems to work or I am not sure really. |
Another unfortunate problemI have to say that, unfortunately, now, the add-on also triggers on the "usual" Mastodon page i.e. my own instance and tries to redirect stuff back to my own instance quite often. Obviously, we should avoid that… 🙃 |
@rugk Oops, I realised this happens when you open a remote instance page in a background tab, because the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise LGTM.
See #84 (comment)