Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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