Skip to content

Instantly share code, notes, and snippets.

@jaywick
Created June 7, 2018 04:34
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 jaywick/c80b5a0ead48bb0216d02d2c767251ae to your computer and use it in GitHub Desktop.
Save jaywick/c80b5a0ead48bb0216d02d2c767251ae to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Github PR Helpers
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Additional tools for reviewing PRs
// @author @jayw
// @match https://YOURGITTHINGY/*/*/pull/*/files*
// @grant none
// ==/UserScript==
(function () {
'use strict';
document.querySelector(".diffbar-item.diffstat").innerHTML += [
`<button type="button" class="btn btn-sm" id="btn-toggle-whitespace">Toggle Whitespace</button>`,
`<button type="button" class="btn btn-sm" id="btn-collapse-expand">Collapse/Expand</button>`,
`<button type="button" class="btn btn-sm" id="btn-expand-hunks">Expand Hunks</button>`].join('\n');
document.querySelector('#btn-toggle-whitespace').onclick = () => {
if (window.location.href.includes('?w=1')) {
window.location.href = window.location.href.replace('?w=1', '')
} else {
window.location.href += '?w=1';
}
}
document.querySelector('#btn-collapse-expand').onclick = () => document.querySelectorAll('.js-details-target').forEach(x => x.click());
document.querySelector('#btn-expand-hunks').onclick = () => document.querySelectorAll('.js-expand').forEach(x => x.click());
console.log('loaded github pr helpers');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment