Skip to content

Instantly share code, notes, and snippets.

@jindrichsirucek
Last active January 24, 2017 21:49
Show Gist options
  • Save jindrichsirucek/3c440b3b951188a2839979d781f2eade to your computer and use it in GitHub Desktop.
Save jindrichsirucek/3c440b3b951188a2839979d781f2eade to your computer and use it in GitHub Desktop.
Script for tampermonkey. Highlites long exectuion times in execution transcript in google apps script browser editor
// ==UserScript==
// @name Highlite long exectuion times in GAS
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Highlite long exectuion times in execution transcript in google apps script
// @author You
// @match https://script.google.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.getElementById(":12").addEventListener("click", function (){setTimeout(function(){highliteTimes();}, 1000);});
function highliteTimes()
{
var textAreaElement = document.getElementsByClassName("script-logging-dialog-content")[0];
var textAreaValue = textAreaElement.value;
var coloredText = textAreaValue.replace(/\n/g,"<br>").replace(/(\d+\.[123456789]+ seconds)/g,function myFunction(inputText)
{
var spanedText = "";
var color = 200 - Math.max(Math.ceil((inputText.match(/\d+\.\d+/)-0),10) * 20);
spanedText = '<span style="background-color: rgb(255,'+color+',255)">'+inputText+'</span>';
console.log(spanedText);
//document.getElementsByClassName("modal-dialog-title-text")[0].innerHTML = spanedText
return spanedText;
});
var coloredElement = document.createElement("div");
coloredElement.setAttribute("style","overflow-y: scroll; height:300px; border:0px black solid");
coloredElement.innerHTML = coloredText;
//textAreaElement.parentElement.appendChild(coloredElement);
//textAreaElement = coloredElement
textAreaElement.parentElement.replaceChild(coloredElement,textAreaElement);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment