Last active
November 16, 2023 23:21
-
-
Save kiliman/c5da74948d85c0063e01174b55ee7d8e to your computer and use it in GitHub Desktop.
Tampermonkey script to update GitHub links to ignore whitespace on diffs
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 Diff Ignore Whitespace | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1.1 | |
// @description Update URL links to ignore whitespace | |
// @author Kiliman | |
// @match https://github.com/* | |
// @icon https://www.google.com/s2/favicons?domain=github.com | |
// @grant none | |
// ==/UserScript== | |
;(function () { | |
'use strict' | |
window.addEventListener('popstate', function () { | |
setTimeout(updateLinks, 1000) | |
}) | |
function updateLinks() { | |
let links = Array.from(document.querySelectorAll('a')).filter(link => | |
/\/pull\/\d+\/(files$|commits\/\w+)$|commit\/\w+$/.test(link.href), | |
) | |
links.forEach(link => { | |
link.href += '?diff=unified&w=1' | |
}) | |
} | |
updateLinks() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment