Skip to content

Instantly share code, notes, and snippets.

@peterflynn
Last active February 13, 2019 16:10
Show Gist options
  • 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")}) }());
@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