Skip to content

Instantly share code, notes, and snippets.

@skjnldsv
Last active July 24, 2023 09:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skjnldsv/d9244cf50d148d4e38319fe497f7b68c to your computer and use it in GitHub Desktop.
Save skjnldsv/d9244cf50d148d4e38319fe497f7b68c to your computer and use it in GitHub Desktop.
Nextcloud drone status check sort
// ==UserScript==
// @name Nextcloud drone status check sort
// @namespace http://drone.nextcloud.com/
// @version 0.3
// @description Put Nextcloud drone failed jobs on top of the list
// @author MorrisJobke & Skjnldsv
// @match https://drone.nextcloud.com/nextcloud/*
// @icon https://github.githubassets.com/favicons/favicon.svg
// @grant none
// @updateURL https://gist.github.com/skjnldsv/d9244cf50d148d4e38319fe497f7b68c/raw/nextcloud-drone-status-sort.user.js
// @downloadURL https://gist.github.com/skjnldsv/d9244cf50d148d4e38319fe497f7b68c/raw/nextcloud-drone-status-sort.user.js
// ==/UserScript==
let init = function (delay) {
var container = document.querySelector('.stages')
if(!container) {
delay = delay * 2;
if(delay === 0) {
delay = 15;
}
if(delay > 500) {
return;
}
setTimeout(function() {init(delay)}, delay);
} else {
var children = Array.prototype.slice.call(container.querySelectorAll('.stage-container'), 0)
while (container.firstChild) {
container.removeChild(container.firstChild);
}
container.append(...children.sort((a, b) => {
return a.querySelector('.status').classList.contains('status-success') - b.querySelector('.status').classList.contains('status-success')
}))
}
};
init(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment