// ==UserScript==
// @name [my & egov].uscis.gov - status changes
// @namespace http://tampermonkey.net/
// @version 0.1
// @description quickly check USCIS case tracker for updates
// @author a VJ user
// @match https://egov.uscis.gov/casestatus/displayLogon.do
// @match https://egov.uscis.gov/casestatus/logon.do
// @match https://egov.uscis.gov/casestatus/portfolioCustomerRetrieve.do
// @match https://my.uscis.gov/account/applicant
// @grant none
// ==/UserScript==
window._settings = {
//////////////// 👇🏽👇🏽👇🏽 PUT DATES, STATUSES, USER & PASSWORD BELOW 👇🏽👇🏽👇🏽 ////////////////
// MIND THE FORMAT OF EVERYTHING HERE WHEN MODIFYING: things
// start with a double quote and end with double quote and a comma
// user & pass can be left blank (but keep double quotes empty and comma after them!)
// if you do, you write them and press the submit button manually on the site
egov_username: "john_doe_88",
egov_password: "secret123",
// exactly as they appear in the egov.uscis.gov column "LAST UPDATED (MM/DD/YYYY)",
// separated by a semicolon (keep the same order as on the site)
egov_dates: "04/20/2018;04/20/2018;05/22/2018",
// exactly as they appear on my.uscis.gov (keep same order)
my_statuses: [
"May 25, 2018",
"We reviewed your biometrics and are still processing your case",
"April 20, 2018",
"We received your case",
"May 25, 2018",
"We reviewed your biometrics and are still processing your case",
]
//////////////// 👆🏽👆🏽👆🏽 THAT WAS ALL THE INFO NEEDED 👆🏽👆🏽👆🏽 ////////////////
}
function show_my_uscis_stuff () {
$("h3.inline-block").not(":nth(0)").click();
var $dates = $("p.panel-pre-title");
var $titles = $("h2.panel-title");
var announcement = false;
for (var i = 0; i < _settings.my_statuses.length / 2; i++) {
var date = _settings.my_statuses[i * 2];
var title = _settings.my_statuses[i * 2 + 1];
var currDate = $dates.eq(i).text();
var currTitle = $titles.eq(i).text();
currStatuses[i * 2] = currDate;
currStatuses[i * 2 + 1] = currTitle;
if (date.trim().toLowerCase() != currDate.trim().toLowerCase() ||
title.trim().toLowerCase() != currTitle.trim().toLowerCase()) {
announcement = "⚠️⚠️⚠️ UPDATED ⚠️⚠️⚠️
" + currDate + "
" + currTitle;
}
}
var theCss = {
"color": "red",
"fontFamily": "impact",
"fontSize": "4em",
"lineHeight": "1em"
};
if (!announcement) {
announcement = "Nothing changed";
theCss.color = "green";
} else {
var toPrint = "my_statuses: [\n";
for (var i = 0; i < currStatuses.length; i++) {
toPrint += '\t"' + currStatuses[i] + '"';
if (i < currStatuses.length - 1) {
toPrint += ",";
if (i % 2 == 1)
toPrint += "\n";
}
toPrint += "\n";
}
toPrint += '];';
console.log(toPrint);
}
$(".uscis-card-content.home-banner-container h2")
.css(theCss)
.html(announcement);
}
function plz_wait () {
if ($("h2.panel-title").length == 3)
show_my_uscis_stuff();
else
setTimeout(plz_wait, 100);
}
(function() {
var loc = window.location.href
// egov.uscis.gov login page
if (!!loc.match(/egov\.uscis.*[lL]ogon.*/)) {
var $myCases = $(".top-link-right a")
if ($myCases.length > 0 && !!$myCases.prop("href").match(/\/casestatus\/portfolioCustomerRetrieve\.do/)) {
$myCases.get(0).click()
} else if ($("#username, #password, #loginBtn").length == 3) {
if (_settings.egov_username && _settings.egov_password) {
$("#username").val(_settings.egov_username)
$("#password").val(_settings.egov_password)
$("#loginBtn").click()
}
}
// egov.uscis.gov case list (the SIMPLE one)
} else if (!!loc.match(/egov\.uscis.*portfolioCustomerRetrieve.*/)) {
var dates = $("tr td.textalign-center:nth-child(3) nobr").text().trim().replace(/\s+/g, ";");
console.log(dates);
var same = (dates == _settings.egov_dates);
$(".logo-sec").remove();
$(".rows.text-center h2").css({"color":(same?"green":"red"),"font-family":"impact"})
.text(same?"Nothing changed":"⚠️ ⚠️ UPDATED ⚠️ ⚠️");
// my.uscis.gov case list (the longer one)
} else if (!!loc.match(/my.uscis.gov\/account\/applicant.*/)) {
window.currStatuses = [];
plz_wait();
}
})();