findepi / Travis show raw log link immediately

// ==UserScript==
// @name         Travis show raw log link immediately
// @namespace    http://joj.io/
// @version      0.4
// @description  Fix Travis #7713
// @author       findepi
// @license      Apache-2.0
// @match        https://travis-ci.org/*/*/jobs/*
// @match        https://travis-ci.com/*/*/jobs/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    setTimeout(add_link, 0);

    function add_link() {
        var match = /^https:\/\/travis-ci.(org|com)\/[-\w]+\/[-\w]+\/jobs\/(\d+)$/.exec(window.location.href);
        if (!match) {
            return;
        }

        var anchor = document.getElementById('tab_log');
        if (!anchor) {
            setTimeout(add_link, 100);
            return;
        }

        anchor = anchor.parentNode.parentNode;
        var li = document.createElement('li');
        anchor.appendChild(li);

        var a = document.createElement('a');
        /*img.src = 'https://www.iconfinder.com/data/icons/iconano-web-stuff/512/109-External-512.png';
        img.height = 32;
        img.width = 32;*/
        a.className = 'ember-view';
        a.innerHTML = 'Raw log';
        a.href = 'https://api.travis-ci.' + match[1] + '/v3/job/' + match[2] + '/log.txt';
        li.appendChild(a);
    }
})();