Created
June 5, 2017 00:02
-
-
Save deecewan/b1536024e7cabdd5358cbd10498f10e9 to your computer and use it in GitHub Desktop.
Add a checkbox to the Github Compare screen to ignore white space. Add this to tampermonkey
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 Github Whitespace | |
// @namespace http://deecewan.com/ | |
// @version 0.1 | |
// @description Add a checkbox to the Github Compare screen to ignore white space. | |
// @author David Buchan-Swanson | |
// @match https://github.com/*/*/compare/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// the element to append to | |
let rangeEditor = document.querySelector('.range-editor'); | |
const checked = window.location.search.includes('w=1'); | |
const label = document.createElement('label'); | |
label.innerText = "Ignore Whitespace?"; | |
const checkbox = document.createElement('input'); | |
checkbox.type = "checkbox"; | |
checkbox.checked = checked; | |
checkbox.style.marginRight = '5px'; | |
label.prepend(checkbox); | |
rangeEditor.append(label); | |
checkbox.addEventListener('change', (e) => { | |
if (e.target.checked) { | |
window.location.search = window.location.search ? window.location.search.concat('&w=1') : '?w=1'; | |
} else { | |
window.location.search = window.location.search.replace('w=1', ''); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment