Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save olets/5083dad8870a4bdb4bf1cee8f38bc14b to your computer and use it in GitHub Desktop.
Save olets/5083dad8870a4bdb4bf1cee8f38bc14b to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name GitHub Ignore Whitespace
// @namespace https://olets.dev/
// @version 1.1
// @description Add URL parameter to ignore whitespace in GitHub pull request reviews
// @author Nimai C. Malle, forked by Henry Bley-Vroman
// @match https://github.com/*/*/pull/*
// @grant none
// @downloadURL https://gist.githubusercontent.com/olets/5083dad8870a4bdb4bf1cee8f38bc14b/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 += '?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] + '?w=1' + matches[2]
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment