Last active
November 2, 2016 21:18
-
-
Save sweeneyapps/d50b00edf4eb7a7874b6de39812719c5 to your computer and use it in GitHub Desktop.
useful script for Rainforest History page.
This file contains 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 Rainforest Jobs | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description collect info from job page | |
// @author Paul Sweeney Jr. | |
// @match https://portal.rainforestqa.com/jobs* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var rfTable = document.getElementsByTagName('table')[0]; | |
var todayDate = new Date(); | |
var todayPaid = 0; | |
var todayPending = 0; | |
var jobCount = 0; | |
var reCurr = /\d+\.\d{1,2}|\d+/; | |
var reCF = /\d+\.0c/; | |
var isCF = false; | |
var CFFIXED = 2; | |
var CFCENT = ""; | |
var DOLLAR = "$"; | |
function cleanCurrency(currStr) { | |
if (reCF.test(currStr)) isCF = true; | |
var cleanCur = currStr.match(reCurr); | |
return cleanCur ? Number(cleanCur[0]) : 0; | |
} | |
function isToday(dateStr) { | |
if (dateStr === '—') return false; | |
var submitDateUTC = dateStr.replace(/ UTC/, ""); | |
var submitDate = new Date(submitDateUTC); | |
return todayDate.getUTCDate() === submitDate.getDate(); | |
} | |
function getCell(row, cell) { | |
return rfTable.rows[row].cells[cell].innerHTML; | |
} | |
for (var i = 1; i < rfTable.rows.length; i++) { | |
if(isToday(getCell(i, 3))) { | |
todayPaid += cleanCurrency(getCell(i,6)); | |
todayPending += cleanCurrency(getCell(i,5)); | |
jobCount += 1; | |
} | |
} | |
if(isCF) { CFFIXED = 1; CFCENT = "c"; DOLLAR = ""; } | |
var info = "Today Paid: " + DOLLAR + todayPaid.toFixed(CFFIXED) + CFCENT + " | Pending: " + DOLLAR + todayPending.toFixed(CFFIXED) + CFCENT + " | Job Count: " + jobCount; | |
alert(info); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks dude, works like a charm.
Btw, I still use your Job Auto-Refresh, I got used to the sound, and ctrl+shift+A comes handy too :)