Forked from NimaiMalle/github_ignore_whitespace.user.js
Last active
September 13, 2021 18:18
-
-
Save olets/5083dad8870a4bdb4bf1cee8f38bc14b to your computer and use it in GitHub Desktop.
This file contains 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 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