Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save stefansundin/5ac159d384d3e4b3a036 to your computer and use it in GitHub Desktop.
Userscript that helps you count the total downloads for your Project Hosting projects.
// ==UserScript==
// @name Google Project Hosting total download count
// @namespace
// @homepage
// @downloadURL
// @version 0.1
// @author Stefan Sundin
// @description Adds a total download count to the footer.
// @match *://*/downloads/list*
// ==/UserScript==
// Useful search term:
// label:Type-Executable OR label:Type-Installer OR label:Type-Package OR label:Type-Archive
// This gives you all downloads except Source and Docs
// Get table
var table = document.getElementById('resultstable');
if (!table) return;
var tr = table.getElementsByTagName('tr');
// Get column #
var colN = null;
for (var i=1; i < tr[0].children.length; i++) {
// Compare text with DownloadCount
if (tr[0].children[i].textContent.indexOf('DownloadCount') != -1) {
colN = i;
if (!colN) return;
// Count the downloads
var count = 0;
for (var i=1; i < tr.length; i++) {
count += parseInt(tr[i].children[colN].textContent, 10);
// Report total
var footer = document.getElementsByClassName('list-foot')[0];
footer.appendChild(document.createTextNode(count+' downloads in total'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment