Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gido
Created May 13, 2015 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gido/f14e149bd382d63c6b0a to your computer and use it in GitHub Desktop.
Save gido/f14e149bd382d63c6b0a to your computer and use it in GitHub Desktop.
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