Skip to content

Instantly share code, notes, and snippets.

@dashed
Forked from asottile-sentry/fails-first.user.js
Created April 26, 2022 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dashed/4df6ea6220437fcbd6f4193932eccdd2 to your computer and use it in GitHub Desktop.
Save dashed/4df6ea6220437fcbd6f4193932eccdd2 to your computer and use it in GitHub Desktop.
// ==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