Last active
June 17, 2017 01:55
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@millerdev has good instructions for how to install here
Installation
Firefox
Chrome