Created
October 11, 2019 04:16
-
-
Save deecewan/f668239bf86d4505d028d9b7bfb3d54f to your computer and use it in GitHub Desktop.
A Tampermonkey script to default to the rich diff for files in a PR if/when they exist
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 Prefer Rich Diffs | |
// @namespace http://deecewan.com/ | |
// @version 0.1 | |
// @description default to rich diffs when they exist for a given filetype | |
// @author You | |
// @match https://github.com/* | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function updatePage() { | |
if (!window.location.pathname.match(/ferocia\/up\/pull\/\d+\/files/i)) { | |
return; | |
} | |
let mounted = true; | |
const unmount = () => { | |
// if we're going to slyly navigate away from this page; | |
mounted = false; | |
} | |
document.addEventListener('pjax:click', unmount); | |
Array.from(document.querySelectorAll('[aria-label="Display the rich diff"]')).forEach(el => el.click()); | |
} | |
document.addEventListener('pjax:end', updatePage); | |
window.addEventListener('load', updatePage); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment