Skip to content

Instantly share code, notes, and snippets.

@clarkwinkelmann
Last active August 27, 2018 19:47
Show Gist options
  • Save clarkwinkelmann/62e8f35fc0e8c3f4b4d17fa83b782052 to your computer and use it in GitHub Desktop.
Save clarkwinkelmann/62e8f35fc0e8c3f4b4d17fa83b782052 to your computer and use it in GitHub Desktop.
Get total time for all events matching search request in Google Calendar webapp
(function () { let total = 0; for (let i=0, times=document.querySelectorAll('.vXnnM');i<times.length; i++) { let hours = times[i].innerText.split('à'); duration = (Date.parse('2017-01-0' + (parseInt(hours[0]) > parseInt(hours[1]) ? '2' : '1') + ' ' + hours[1]) - Date.parse('2017-01-01 ' + hours[0])); /*console.log(duration/60000);*/ total += duration; } let totalMinutes = total / 60000; return Math.floor(totalMinutes / 60) + ':' + (totalMinutes % 60); })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment