NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name autotest time offset // @namespace arista // @version 0.1 // @description display test start time in local time/date // @author You // @match http://autotest/* // @grant none // ==/UserScript== (function() { 'use strict'; function pad_leading_zeros(str, len) { if (!(str instanceof String)) { str = String(str); } while (str.length < len) { str = '0' + str; } return str; } var tbs = document.getElementsByTagName("tbody"); var tb = null; var e, i, j; for (i = 0; i < tbs.length; i++) { var t = tbs.item(i); var tr0 = t.firstElementChild; var tcn0 = tr0.children[0]; var tcn1 = tr0.children[1]; if ((tcn0.tagName === "th" || tcn0.tagName === "TH") && tcn0.textContent === "Change" && (tcn1.tagName === "th" || tcn1.tagName === "TH") && tcn1.textContent === "Id") { tb = t; break; } } var time_reg = /^\s*(\d\d)\/(\d\d)\s+(\d\d):(\d\d)\s*$/; var year = (new Date()).getFullYear(); var time_offset_src = "-08:00"; var tou = (new Date()).getTimezoneOffset(); var time_offset_user = (tou < 0)? '-' : '+'; tou = Math.abs(tou); time_offset_user += pad_leading_zeros((tou / 60).toFixed(), 2); time_offset_user += ':' + pad_leading_zeros((tou % 60).toString(10), 2); if (tb) { var trs = tb.children; var th = trs.item(0); for (i = 0; i < th.children.length; i++) { e = th.children.item(i); if (e.textContent === "Start") { e.textContent = "Start (Local)"; } } for (i = 1; i < trs.length; i++) { var tr = trs.item(i); var se = null; var sm = null; for (j = 0; j < tr.children.length; j++) { e = tr.children.item(j); var text = e.textContent; sm = text.match(time_reg); if (sm) { se = e; break; } } if (se) { var month = sm[1]; var day = sm[2]; var hour = sm[3]; var minute = sm[4]; //YYYY-MM-DDThh:mmTZD var utc = new Date(year.toString(10) + '-' + month + '-' + day + 'T' + hour + ':' + minute + time_offset_src); var local_time = pad_leading_zeros(utc.getMonth()+1, 2) + '/' + pad_leading_zeros(utc.getDate(), 2); local_time += ' ' + pad_leading_zeros(utc.getHours(), 2) + ':' + pad_leading_zeros(utc.getMinutes(), 2); se.textContent += '\n(' + local_time + ')'; } } } })();