Last active
August 29, 2015 14:06
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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