Skip to content

Instantly share code, notes, and snippets.

@xxswingxx
Last active October 4, 2021 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xxswingxx/af32c9fe3a3ec0af09c4dc196b34a29d to your computer and use it in GitHub Desktop.
Save xxswingxx/af32c9fe3a3ec0af09c4dc196b34a29d to your computer and use it in GitHub Desktop.
A Tampermonkey / Greasemonkey userscript to hide Hound conversations in Github PRs
// ==UserScript==
// @name Toggle Hound
// @namespace ToggleHoundInGithub
// @version 0.1
// @description Toggle Hound conversations in Github PRs
// @author xxSwingxx
// @match https://github.com/*pull*
// @icon https://www.google.com/s2/favicons?domain=tampermonkey.net
// @grant none
// ==/UserScript==
// Key combination ctrl + shift + dot
(function() {
'use strict';
//dotkeycode
var keycodes = [190];
var hideCaption = 'Hide Hound comments';
var showCaption = 'Show Hound comments';
var toggler = document.createElement('div')
var togglerButton = document.createElement('button');
var body = document.body;
toggler.id = 'toggleHoundComments'
toggler.style.position = 'fixed';
toggler.style.right = '100px';
toggler.style.bottom = '0';
toggler.style.height = '200px';
toggler.style.width = '130px';
toggler.style.zIndex = '1000'
togglerButton.textContent = hideCaption;
togglerButton.id = 'togglerButton';
togglerButton.classList.add('btn');
togglerButton.classList.add('m-3');
toggler.appendChild(togglerButton);
body.prepend(toggler);
var toggleHound = function() {
let display = null;
document.querySelectorAll('.TimelineItem-body > div > strong > .author[href="/apps/hound"]').forEach(function(ele) {
display = ele.closest('.js-timeline-item').offsetLeft <= 0 ? 'block' : 'none'
ele.closest('.js-timeline-item').style.display = display;
})
togglerButton.textContent = display == 'none' ? showCaption : hideCaption;
return false;
}
toggler.addEventListener('click', function(e) {
toggleHound();
e.cancelBubble = true;
e.stopImmediatePropagation();
})
document.addEventListener('keydown', function(e) {
if (keycodes.indexOf(e.keyCode) != -1 && e.ctrlKey && e.shiftKey) {
toggleHound();
e.cancelBubble = true;
e.stopImmediatePropagation();
}
return false;
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment