Last active
June 26, 2023 05:09
-
-
Save NimaiMalle/9f1ddac7784632ba1b9b72f753dbcdf4 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 GitHub Ignore Whitespace | |
// @namespace http://spicewood.tech/ | |
// @version 1.1 | |
// @description Add URL parameter to ignore whitespace in GitHub pull request reviews | |
// @author Nimai C. Malle | |
// @match https://github.com/*/*/pull/* | |
// @grant none | |
// @downloadURL https://gist.githubusercontent.com/NimaiMalle/9f1ddac7784632ba1b9b72f753dbcdf4/raw/github_ignore_whitespace.js?v=1.1 | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const tabs = document.getElementsByClassName('tabnav-tab') | |
for (let e of tabs) { | |
if(e.nodeName==='A' && e.href.endsWith('files')) { | |
e.href += '?utf8=✓&diff=split&w=1' | |
} | |
} | |
const buttons = document.getElementsByClassName('btn') | |
const filesRegex = /(.*\/files)(#.*|$)/ | |
var matches | |
for (let e of buttons) { | |
if(e.nodeName==='A' && (matches = e.href.match(filesRegex)) ) { | |
e.href = matches[1] + '?utf8=✓&diff=split&w=1' + matches[2] | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment