Skip to content

Instantly share code, notes, and snippets.

@singingwolfboy
Forked from mulby/comment_expander.js
Last active August 29, 2015 14:15
Show Gist options
  • Save singingwolfboy/575f7d005146ba3b235f to your computer and use it in GitHub Desktop.
Save singingwolfboy/575f7d005146ba3b235f to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Github Expand All Comments
// @namespace http://www.edx.org/developers
// @version 0.1
// @description Help manage github pull request comments
// @match *://github.com/*/pull/*
// @copyright 2014+, Gabe Mulley
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
// ==/UserScript==
menuobj = document.createElement('div');
menuobj.style.position = 'fixed';
menuobj.style.top = '10px';
menuobj.style.left = '10px';
menuobj.style.backgroundColor = '#ffffff00';
menuobj.innerHTML = '<input id="toggle-all-comments" type="button" value="Show All Comments" />';
body = document.getElementsByTagName('body')[0];
body.appendChild(menuobj);
$('#toggle-all-comments').click(function(e) {
$('.discussion-item-toggle-closed').each(function (i, el) {
var evt = document.createEvent("MouseEvents");
evt.initEvent("click", true, true);
el.dispatchEvent(evt);
});
button = $( this )
if (button.prop('value') == 'Show All Comments') {
button.prop('value', 'Hide All Comments');
} else {
button.prop('value', 'Show All Comments');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment