Last active
August 29, 2015 14:26
-
-
Save esoergel/664d00ade2324048f6ff to your computer and use it in GitHub Desktop.
This file contains hidden or 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 > .btn-group").prepend('<a class="btn btn-sm" 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