Created
June 28, 2017 02:00
-
-
Save kyoh86/18e7a1399544d54e9867fea4f6cccfa3 to your computer and use it in GitHub Desktop.
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
| (() => { | |
| const interval = 2000; | |
| const markAttribute = "data-diff-additions-only"; | |
| const process = () => { | |
| let additionsOnly = /[\?&]diff-additions-only=true/.test(window.location.search); | |
| let controller = document.querySelectorAll("#files_bucket > div.pr-toolbar .pr-review-tools .BtnGroup").forEach(btnGroup => { | |
| if (btnGroup.hasAttribute(markAttribute)) { | |
| return; | |
| } | |
| btnGroup.setAttribute(markAttribute, true); | |
| if (additionsOnly) { | |
| btnGroup.innerHTML = | |
| '<button type="button" class="btn btn-sm btn-outline BtnGroup-item tooltipped tooltipped-s bg-gray-light text-gray-light" aria-label="Viewing additions only" disabled="">Additions</button>' + | |
| '<a class="btn btn-sm btn-outline BtnGroup-item tooltipped tooltipped-s" href="./files?diff=unified" aria-label="View diff in unified mode">Unified</a>' + | |
| '<a class="btn btn-sm btn-outline BtnGroup-item tooltipped tooltipped-s" href="./files?diff=split" aria-label="View diff in split mode">Split</a>'; | |
| } else { | |
| btnGroup.innerHTML = | |
| '<a class="btn btn-sm btn-outline BtnGroup-item tooltipped tooltipped-s" aria-label="View additions only" href="./files?diff=unified&diff-additions-only=true">Additions</a>' + | |
| btnGroup.innerHTML; | |
| } | |
| }); | |
| if (additionsOnly) { | |
| document.querySelectorAll(".blob-num-deletion").forEach(cell => { | |
| cell.parentElement.style.display = "none"; | |
| }); | |
| } | |
| window.setTimeout(process, interval); | |
| }; | |
| process(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment