# Show total amounts on reports by range

**URL:** <https://meta.discourse.org/t/show-total-amounts-on-reports-by-range/35024>\
**Category:** Feature\
**Created:** [28 أكتوبر 2015، 5:15م UTC](https://meta.discourse.org/t/show-total-amounts-on-reports-by-range/35024 "2015-10-28T17:15:20Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)\
**Post date:** [28 أكتوبر 2015، 5:21م UTC](https://meta.discourse.org/t/show-total-amounts-on-reports-by-range/35024/2 "2015-10-28T17:21:48Z")

</div>

Do you have any experience writing browser extensions?

I threw this together for Firefox but I imagine a Chrome extension would be similar

```plaintext
self.port.on('viewing_admin_reports_visits', function () {
"use strict";
	var visit_cells = document.querySelectorAll("table[class~='report'] tbody tr td");
	var h3_heading = document.querySelector("div#main-outlet h3");
	var visit_cells_len = visit_cells.length;

	var high_visit = 0;
	var high_visit_cell_num = 0;
	var total_count = 0;

	for (var i = 0; i < visit_cells_len; i++) {
		if (/[\d]{4}-[\d]{2}-[\d]{2}/.test(visit_cells[i].textContent)) {
			var ymd_date = new Date(visit_cells[i].textContent);
			if ( (ymd_date.getUTCDay() == 6) || (ymd_date.getUTCDay() == 0) ) {
				visit_cells[i].parentNode.setAttribute('style', "background-color: #efefff");
			}
		}
		if (/\s[\d]+\s/.test(visit_cells[i].textContent)) {
			total_count += parseInt(visit_cells[i].textContent);
			if (parseInt(visit_cells[i].textContent) > high_visit) {
				high_visit = parseInt(visit_cells[i].textContent);
				high_visit_cell_num = i;
			}
		}
	}
	visit_cells[high_visit_cell_num].setAttribute('style', "font-weight: bold; font-size: 1.2em");

	var avg_span = document.createElement('span');
	avg_span.textContent = " - average " + Math.round(total_count / (visit_cells_len / 2) ) + " per day";
	h3_heading.appendChild(avg_span);
});

```

---

_[View the full topic](https://meta.discourse.org/t/show-total-amounts-on-reports-by-range/35024)._
