// ==UserScript== // @name github-ignore-whitespace // @namespace http://tampermonkey.net/ // @version 0.1 // @description Github always ignore whitespace when reviewing a PR // @author You // @include https://github.com/* // @icon https://www.google.com/s2/favicons?domain=undefined.localhost // @grant GM_addStyle // ==/UserScript== const set = () => { const href = window.location.href console.log("checking page...", href) if (href.endsWith("/files")) { console.info("pull request is not ignoring whitespace -- redirecting") window.location.replace(`${href}?w=1`) } for (const annotation of document.getElementsByClassName('check-annotation')) { annotation.style.display = "none" } } set() var oldHref = document.location.href; window.onload = function () { var bodyList = document.querySelector("body") var observer = new MutationObserver(function (mutations) { if (oldHref != document.location.href) { oldHref = document.location.href; set() } }); var config = { childList: true, subtree: true }; observer.observe(bodyList, config); };