Last active
March 22, 2021 12:46
-
-
Save dannylagrouw/3e7d528b15b069e879e909424af4d8fb to your computer and use it in GitHub Desktop.
TamperMonkey script for jumping to failed tests in Semaphore build output by clicking on red "Failed in ..." button
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 Semaphore jump to FAILED | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://nedap.semaphoreci.com/jobs/* | |
// @grant GM_addStyle | |
// ==/UserScript== | |
// https://gist.github.com/dannylagrouw/3e7d528b15b069e879e909424af4d8fb | |
(function() { | |
'use strict'; | |
var lastPos = 0; | |
window.addEventListener('load', function() { | |
GM_addStyle('.myButton {' + | |
' box-shadow: 3px 4px 11px 1px #8a2a21;' + | |
' background:linear-gradient(to bottom, #c62d1f 5%, #f24437 100%);' + | |
' background-color:#c62d1f;' + | |
' border-radius:42px;' + | |
' border:9px solid #d02718;' + | |
' display:inline-block;' + | |
' cursor:pointer;' + | |
' color:#ffffff;' + | |
' font-family:Arial;' + | |
' font-size:17px;' + | |
' font-weight:bold;' + | |
' padding:7px 25px;' + | |
' text-decoration:none;' + | |
' text-shadow:0px 1px 0px #810e05;' + | |
'}' + | |
'.myButton:hover {' + | |
' background:linear-gradient(to bottom, #f24437 5%, #c62d1f 100%);' + | |
' background-color:#f24437;' + | |
'}' + | |
'.myButton:active {' + | |
' position:relative;' + | |
' top:1px;' + | |
'}' + | |
'.myButton:focus {' + | |
' outline:none;' + | |
'}'); | |
window.setTimeout(function() { | |
document.querySelector('#job-log-container').style.height = '67vh'; | |
}, 500); | |
// var jobstate = document.getElementById('job-state'); | |
// var jobstate = document.querySelector('#main-content .pollman-container .f7') | |
var button = document.createElement('button'); | |
button.innerText = 'Next Error'; | |
button.className = 'myButton'; | |
// button.style.backgroundColor = '#e53935'; | |
// button.style.color = 'white'; | |
document.querySelector('#main-content h1').insertAdjacentElement('afterend', button); | |
button.addEventListener('click', function() { | |
// var faileds = Array.from(document.querySelectorAll('#log-table td.output span')) | |
var faileds = Array.from(document.querySelectorAll('#job-log .job-log-line-body > span')) | |
.filter( | |
function(e) { | |
return e.innerText.endsWith(' FAILED'); | |
}); | |
faileds.forEach(function(e) { | |
e.parentElement.style.color = 'white'; | |
e.parentElement.style.backgroundColor = '#e53935'; | |
}); | |
button.innerText = 'Next Error (' + (lastPos + 1) + '/' + faileds.length + ')'; | |
// var logContainer = document.getElementById('log-container'); | |
var logContainer = document.getElementById('job-log'); | |
var containerPos = logContainer.scrollTop; | |
if (faileds && faileds.length > 0) { | |
faileds[lastPos].scrollIntoView({smooth: true, block: 'center'}); | |
if (faileds.length > lastPos + 1) { | |
lastPos++; | |
} else { | |
lastPos = 0; | |
} | |
} | |
}); | |
}, false); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment