Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stefansundin/5ac159d384d3e4b3a036 to your computer and use it in GitHub Desktop.
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 https://gist.github.com/stefansundin/
// @homepage https://gist.github.com/stefansundin/5ac159d384d3e4b3a036
// @downloadURL https://gist.github.com/stefansundin/5ac159d384d3e4b3a036/raw/google-project-hosting-download-counter.user.js
// @version 0.1
// @author Stefan Sundin
// @description Adds a total download count to the footer.
// @match *://code.google.com/p/*/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;
break;
}
}
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