-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Does not trigger HTML insertion on SPA-like navigation #13
Comments
Possible solution? Haven't tested it. diff --git a/src/js/main.js b/src/js/main.js
index c62ef70..4f44dd0 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -245,3 +245,13 @@ function fixCommitsPageStyle (menuElement) {
window.onload = init;
init();
+
+// Caniuse: https://caniuse.com/mdn-api_navigation
+// Chrome dev article: https://developer.chrome.com/docs/web-platform/navigation-api/#try-the-navigation-api:~:text=navigation.addEventListener(%27navigatesuccess%27%2C%20event%20%3D%3E%20%7B%0A%20%20loadingIndicator.hidden%20%3D%20true%3B%0A%7D)%3B
+try {
+ navigation.addEventListener('navigatesuccess', event => {
+ init()
+ });
+} catch {
+ // IDK what to do for a fallback
+} |
Hi @jcbhmr. Line 162 in 861b31e
|
Update: |
EDIT: Even though it looked like a Chrome-only extension at first glance from the description/link at the top, I double-checked and now see that it has a Firefox counterpart. This means this solution WON'T work.
If not, IDK what to do... Thoughts? Can I use link: https://caniuse.com/mdn-api_navigation |
Another thing you could use as an indicator is a It might not even be that big of a performance hit since you can trim down what the browser watches for to be only direct children: |
I went digging for GitHub-specific events that they use. Turns out there is a collection of I added a listener to the |
Fixed now in v2.0.3, using the |
GitHub uses an SPA-like navigation system which does magic ✨ to avoid triggering a full page reload. This means that the HTML injection that is done once doesn't happen again when a non-navigation-but-still-sorta-navigation event occurs when the user changes "tabs" in the repo.
Video of what I am talking about:
https://user-images.githubusercontent.com/61068799/177011417-7976339c-1971-46e6-b4f3-b3246bfbd4fb.mp4
Listening for some kind of URL/history/navigation-related event and re-triggering the
init()
call might fix it? I don't really know.Maybe relevant links:
There looks to be like 4 more StackOverflow questions basically asking the same thing and all getting basic: "you monkeypatch the history.pushState() method" answers:
The text was updated successfully, but these errors were encountered: