Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bookmarlet to display/preview the total hours in Harvest Estimate
var totalH = 0;
var hours = document.getElementsByClassName('item-qty desktop');
Array.prototype.forEach.call(hours, function(el) { totalH += parseFloat(el.innerHTML); });
var totalRow = document.querySelector('tr.total');
var totalLabelCol = document.querySelector('tr.total td.label');
var totalAmoundCol = document.querySelector('tr.total td.total');
var totalHoursCol = document.createElement('td');
totalHoursCol.innerHTML = totalH;
totalRow.insertBefore(totalHoursCol, totalAmoundCol);
totalLabelCol.setAttribute('colspan', 2);
totalAmoundCol.setAttribute('colspan', 2);
<html>
<head>
<title>Install my Harvest bookmarklet</title>
</head>
<body>
<h2>Bookmarlet to display/preview the total hours in Harvest Estimate</h2>
<p>
Drag the following link into your favorite bar to install:
<a href="javascript:(function(){var totalH=0;var hours=document.getElementsByClassName('item-qty desktop');Array.prototype.forEach.call(hours,function(el){totalH+=parseFloat(el.innerHTML);});var totalRow=document.querySelector('tr.total');var totalLabelCol=document.querySelector('tr.total td.label');var totalAmoundCol=document.querySelector('tr.total td.total');var totalHoursCol=document.createElement('td');totalHoursCol.innerHTML=totalH;totalRow.insertBefore(totalHoursCol,totalAmoundCol);totalLabelCol.setAttribute('colspan',2);totalAmoundCol.setAttribute('colspan',2);})();">Harvest Add Total Hours</a>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment