Skip to content

Instantly share code, notes, and snippets.

@sweeneyapps
Last active November 2, 2016 21:18
Show Gist options
  • Save sweeneyapps/d50b00edf4eb7a7874b6de39812719c5 to your computer and use it in GitHub Desktop.
Save sweeneyapps/d50b00edf4eb7a7874b6de39812719c5 to your computer and use it in GitHub Desktop.
useful script for Rainforest History page.
// ==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);
})();
@mobradovic
Copy link

Hey Paul, how do I install this?

@sweeneyapps
Copy link
Author

it's for http://tampermonkey.net/

You download extension from tampermonkey and create a new script there then copy and paste the script from here to there.

@mobradovic
Copy link

Thanks man.

I'm having 80c pending (on the page), but script says "Pending 0,0c".
Anything I can do to fix that?

@sweeneyapps
Copy link
Author

I just fixed that. new update.. just refresh this page.

@mobradovic
Copy link

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 :)

@sweeneyapps
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment