Skip to content

Instantly share code, notes, and snippets.

@NimaiMalle
Last active June 26, 2023 05:09
Show Gist options
  • Save NimaiMalle/9f1ddac7784632ba1b9b72f753dbcdf4 to your computer and use it in GitHub Desktop.
Save NimaiMalle/9f1ddac7784632ba1b9b72f753dbcdf4 to your computer and use it in GitHub Desktop.
// ==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