Skip to content

Instantly share code, notes, and snippets.

@esoergel
Last active June 17, 2017 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save esoergel/6b025ae378614dc2cbf9 to your computer and use it in GitHub Desktop.
Save esoergel/6b025ae378614dc2cbf9 to your computer and use it in GitHub Desktop.
Adds a button to github diffs to append ?w=1 to the diff url, ignoring whitespace.
// ==UserScript==
// @name Ignore whitespace button
// @namespace github-ignore-whitespace
// @description Adds a button to github diff views to toggle the "ignore whitespace" option.
// @include https://github.com/*
// @version 1
// @grant none
// ==/UserScript==
function main() {
$("#toc > .button-group").prepend('<a class="minibutton" href="?w=1">Ignore whitespace</a>');
}
window.addEventListener('load', function () {
if (typeof $ === 'undefined') {
// load jQuery : http://stackoverflow.com/a/4261831/10840
var script = document.createElement('script');
script.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
script.addEventListener('load', function () {
var script = document.createElement('script');
script.textContent = 'window.jQ=jQuery.noConflict(true);(' + main.toString() + ')();';
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
} else {
main();
}
});
@esoergel
Copy link
Author

@millerdev has good instructions for how to install here

Installation

Firefox

  • Install Greasemonkey. Be sure to restart your browser to complete the installation when prompted.
  • Click the Raw button above the script on this page. You should see a Greasemonkey Installation dialog.
  • Click Install.

Chrome

  • Install Tampermonkey
  • Click the Raw button above the script on this page. Tampermonkey should prompt you to install the script.
  • Click Install.

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