-
-
Save dashed/4df6ea6220437fcbd6f4193932eccdd2 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 fails-first | |
// @namespace https://asottile.dev | |
// @version 0.1 | |
// @description put failed statuses first | |
// @author asottile | |
// @match https://github.com/*/*/pull/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const observer = new MutationObserver((_, observer) => { | |
const lst = document.querySelector('.merge-status-list.js-updatable-content-preserve-scroll-position'); | |
if (!lst) { | |
return; | |
} | |
let fails = []; | |
let pending = []; | |
let skipped = []; | |
for (let child of lst.querySelectorAll('.merge-status-item')) { | |
if (child.querySelector('.octicon-skip')) { | |
child.parentNode.removeChild(child); | |
skipped.push(child); | |
} else if (child.querySelector('.octicon-x')) { | |
child.parentNode.removeChild(child); | |
fails.push(child); | |
} else if (child.querySelector('.anim-rotate, .octicon-dot-fill')) { | |
child.parentNode.removeChild(child); | |
pending.push(child); | |
} | |
} | |
lst.prepend(...fails, ...pending, ...skipped); | |
observer.takeRecords(); // prevent recursing infinitely | |
}); | |
const cont = document.querySelector('.pull-discussion-timeline'); | |
if (cont) { | |
observer.observe(cont, {childList: true, subtree: true}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment