AppVeyor Console Timestamp

Displays line timestamps in the job console

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==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       [email protected]
// ==/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;
  }
})();