Comments (19)
I just added a How to wiki page with my current take on how I deal with GitHub and progressively loaded content. Let me know what you guys think.
from github-userscripts.
Try the update I just pushed.
from github-userscripts.
All examples on this page are working for me too now 🎉
from github-userscripts.
@jerone I was not originally using pjax:
events because they weren't firing in the situations outlined below; but using only mutation observers turned out to be not so great for performance. In this last update, I switched to using a mixed method which still isn't ideal.
You probably already know most of the information below, but I'm sharing all of my findings so that other developers may benefit from my research in this topic. I'm sure there are better solutions, but I was going cross-eyed from looking at GitHub's minified javascript.
pjax
containers
The pjax:end
event only fires when the #js-repo-pjax-container
or #js-pjax-container
content is updated. These overall content blocks are updated when changing pages on GitHub.
Progressive containers
Files changed
There are two progressive containers in the "Files changed" tab. The first container usually has content (less than 4 files), while the second loads in more content dynamically.
To detect changes here, I had to set up MutationObserver
s on the .js-diff-progressive-container
and .js-diff-load-container
elements. I filtered out all changes that did not involve either the .js-diff-load-container
or .blob-wrapper
elements. A 500 ms delay was added here as the observer would appear to fire before the content had completed rendering. I tried using 300 ms but it wouldn't catch the second container updates after switching from either the "Conversation" or "Commits" tab to the "Files changed" tab. Refreshing the browser on the "Files changed" tab almost always works if it didn't catch everything while switching tabs.
Discussion blocks
When issue discussions get really long, a "View more" (.timeline-progressive-disclosure-button
) button is added in the timeline (example) to allow progressive loading of comments. This button only loads 200 additional comments, so listening for a button click isn't ideal here.
In this situation, a mutation observer targets the .js-discussion
wrapper element for updates. In my code, I haven't filtered out all changes within this element, but it would be a good idea since changing reactions causes the observer to fire off.
Previews
Comment previews fire off a "preview:setup" event on the document
when a "Preview" tab is hovered or clicked. Sadly, a document
"preview:render" event only fires when the keyboard shortcut (ctrl shift p) key is used.
I ended up listening for the "preview:setup" event after a 500ms
delay... again, not an ideal solution 😞.
I think I'll copy the above content over into a wiki page.
from github-userscripts.
Yep now it seems to be working 😄 👍
from github-userscripts.
Hi @duianto!
Thanks for letting me know! I've been trying to fix this issue... give me a little more time to get it working properly in all cases.
from github-userscripts.
Ok, I think I got it all fixed...
I've noticed that sometimes, when navigating from another page or tab to the "Files changed" tab, the dynamically loaded content doesn't always get processed. I added a 500ms delay which may, or may not process the new content; and attempts to get it to alway work have come up short.
Reloading the page should always work.
from github-userscripts.
And using pjax
-event doesn't solve it?
from github-userscripts.
I updated the script in Tampermonkey and now it says:
GitHub Remove Diff Signs 1.1.0 (last updated 2h)
Ok, I think I got it all fixed...
Unfortunately there doesn't seem to have been any change in the first two example links above, the same number of files have their signs removed and the rest are still showing signs.
The third example also look the same when the page first loads, the last two visible files show signs. But when one clicks on "Load diff ..." on one of the two hidden files to show the code, then the revealed code shows the signs for half a second (as expected with the added 500ms delay), then the signs for all three visible files get removed. And when the "Load diff ..." is clicked to show the code for the last hidden file, then it also shows the signs for half a second before they are removed.
Reloading the page should always work.
Nothing changes in any of the 3 examples when the pages are reloaded.
I took a screenshot of the Network tab in Chromes Developer Tools when the first example link loads:
https://github.com/Mottie/tablesorter/pull/195/files
The content.min.css
file, says (from disk cache), i tried holding down any combination of Ctrl
and Shift
to not load from cache but that file always loads from cache. When i held down Alt
then all the files
in the Initiator column were loaded from cache.
from github-userscripts.
Odd, I've been testing the userscript on all 3 of those pages...
from github-userscripts.
I can see it working 3 out of 4 times with above example page loading.
from github-userscripts.
It's working every time for me. Internally there is a loop that removes the +/- signs at intervals to allow continued user interaction with the page.
from github-userscripts.
This page is consistently not working: https://github.com/Mottie/Keyboard/pull/363/files
No errors in console.
Edit: only at load time, after opening one of the hidden diffs it works.
from github-userscripts.
Which blocks?
from github-userscripts.
@Mottie commented on 25 mrt. 2017 16:31 CET:
Which blocks?
All blocks, but only at load time. After force opening one of the hidden diffs, all signs are removed.
from github-userscripts.
I disabled all but one chrome extension tampermonkey, closed all but this tab, restarted chrome, turned off all other applications, including the once that were running in the system tray, i even restarted the computer and tested the examples between each step. The first two examples always work as described in the initial report. But the third example sometimes open with the 2 visible files having their signs removed. But every time i refresh the third examples tab, then the signs are shown again with or without Ctrl
or Shift
held down to not load from cache (maybe it shouldn't matter).
from github-userscripts.
I'm on GreaseMonkey in Firefox. Also tested with and without cache. Calling processDiff()
function manually does remove the signs.
from github-userscripts.
Derp... ok I think I see the problem LOL. Odd that it was working fine in Chrome, but not in Firefox.
from github-userscripts.
I added these logs before and after the if query selector line:
console.log("pre .highlight");
if (document.querySelector(".highlight")) {
console.log("in .highlight");
and when the page:
https://github.com/Mottie/Keyboard/pull/363/files
loads then only the "pre .highlight" message appears in the developer tools console, but when i click on "Load diff" to show the code for one of the two files, then both the pre
and in
messages are shown in the console.
from github-userscripts.
Related Issues (20)
- feature request? bug?: GitHub issue comments: support hiding linked commits HOT 5
- FireMonkey Compatibility
- Custom navigation formatting on github projects page HOT 6
- Github Title Notification is broken HOT 8
- Feature request: show source code structure (list of classes, methods, functions, etc.)
- "GitHub Diff Filename" only work when reloading on the diff page HOT 4
- Greasy Fork followup
- github-static-time: Option to show UTC HOT 5
- Mutations not firing when clicking "Pull Requests" tab
- GitHub Watcher issue: Some repositories are not uploading HOT 3
- scripts doesn't work when enter the page first time HOT 2
- Request: add script of README.md editor
- GitHub Sort Content no longer works when logged in HOT 3
- GitHub code folding - the last block does not get a folding arrow
- GitHub static time - prevent text wrapping?
- Open Extension Page is just broken now. HOT 6
- [Request]Filter Forks by Releases
- Github Image Preview not visible on repos
- [Feature Request] GitHub Static Time: Enhance Match to Fit Also Gists And More
- [Feature Request] GitHub Static Time: Also Process Lazy Loaded Content
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from github-userscripts.