Skip to content

Instantly share code, notes, and snippets.

@peterflynn
Last active February 13, 2019 16:10
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterflynn/5980273 to your computer and use it in GitHub Desktop.
Save peterflynn/5980273 to your computer and use it in GitHub Desktop.
Bookmarklet to expand all collapsed comments in a GitHub pull request (places where it says "discussed an outdated diff")
// DEPRECATED: See "Expand All Comments" at https://gist.github.com/peterflynn/ace5dd3d7a8ec645cd42 for
// a more up to date, maintained version of this.
// Original bookmarklet from this gist (does not work anymore):
// javascript:(function() { $(".outdated-diff-comment-container").addClass("open"); }());
// Newer, working version (from link above as of Jan 2017):
// javascript:(function() { document.querySelectorAll(".outdated-diff-comment-container").forEach(function(n) {n.classList.add("open")}) }());
@Garrett-R
Copy link

I followed Firefox's instruction to install a bookmarklet to install this one, then I ran it on this PR and it doesn't seem to do anything...

This would be really useful to me, so I'm really hoping I can get it working.

@cynipe
Copy link

cynipe commented Jul 17, 2015

@ibizaman
Copy link

And as a bookmarklet:

javascript:(function() {var interval = setInterval(function() {     var expandPoints = $(".octicon.octicon-unfold");     expandPoints ? expandPoints.click() : clearInterval(interval); }, 2000);}())

@jessejoe
Copy link

jessejoe commented Jun 6, 2016

I think this stopped working. Doesn't look like github loads jQuery anymore, or at least $ isn't bound to it. I rewrote this in pure javascript and it works:

javascript:(function() { 
elements = document.getElementsByClassName("outdated-diff-comment-container");
for (var i=0; i<elements.length; i++) { elements[i].className += " open"; }
}());

Not sure if there's a better way (I'm not a JS guy).

@BurntSushi
Copy link

@jessejoe worked for me, thanks!

@compact
Copy link

compact commented Nov 1, 2016

The class name for the container has since changed to outdated-comment.

@dgolden1
Copy link

Updated version:

javascript:Array.from(document.getElementsByClassName('outdated-comment')).forEach(l => l.classList.add('open'));

Thanks to yuichiro-yoshida's comment at https://coderwall.com/p/akdgoq/expand-all-outdated-diff-comments-in-a-github-pull-request

@yuichiro-yoshida
Copy link

Updated version:

javascript: Array.from(document.getElementsByClassName('outdated-diff-comment-container'))
.concat(Array.from(document.getElementsByClassName('outdated-comment')))
.forEach(l => l.classList.add('open'));

Detail:
https://coderwall.com/p/akdgoq/expand-all-outdated-diff-comments-in-a-github-pull-request

@sgabler
Copy link

sgabler commented Dec 2, 2017

In case you are interested: This was recently implemented in the browser extension sindresorhus/refined-github

@laurenbrandstein
Copy link

Updated JS bookmark for recent Github redesign:
javascript:Array.from(document.getElementsByClassName('outdated-comment')).forEach(l => l.setAttribute('open',true));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment