-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathappveyor-console-timestamp.user.js
More file actions
64 lines (58 loc) · 1.84 KB
/
appveyor-console-timestamp.user.js
File metadata and controls
64 lines (58 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// ==UserScript==
// @name AppVeyor Console Timestamp
// @version 0.7
// @description Displays line timestamps in the job console
// @license https://creativecommons.org/licenses/by-sa/4.0/
// @namespace http://github.com/tony19
// @match https://ci.appveyor.com/*/build/*
// @grant GM_addStyle
// @run-at document-idle
// @author tony19@gmail.com
// @updateURL https://github.com/tony19/appveyor-userscripts/raw/master/appveyor-console-timestamp.user.js
// @downloadURL https://github.com/tony19/appveyor-userscripts/raw/master/appveyor-console-timestamp.user.js
// ==/UserScript==
/* global GM_addStyle */
/* jshint esnext:true, unused:true */
(() => {
'use strict';
GM_addStyle(`
div[title] a:first-child {
width: 140px !important;
background-color: black;
}
div[title] span:first-child {
padding-left: 100px !important;
}
.job-console {
background-color: black;
}
a.late {
color: red;
}
`);
// number of seconds between timestamps that indicate excessive time spent
const HIGH_WATERMARK = 3;
let lastTime = '';
const timerId = setInterval(() => {
const divs = $('div[title]:has(a):not([data-ts])');
if (!divs || !divs.length) { return; }
divs.each((index, div) => {
const timestamp = div.getAttribute('title');
const anchor = $(div).find('a:first-child').append(` - ${timestamp}`);
processLine(anchor, timestamp);
});
divs.attr('data-ts', '');
}, 2000);
function processLine(anchor, timestamp) {
const seconds = toSeconds(timestamp);
if (seconds - lastTime >= HIGH_WATERMARK) {
$(anchor).addClass('late');
}
lastTime = seconds;
}
function toSeconds(hms) {
const a = hms.split(':');
const seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
return seconds;
}
})();