Advertisement
Guest User

[my & egov].uscis.gov - status changes

a guest
Jul 5th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         [my & egov].uscis.gov - status changes
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  quickly check USCIS case tracker for updates
  6. // @author       a VJ user
  7. // @match        https://egov.uscis.gov/casestatus/displayLogon.do
  8. // @match        https://egov.uscis.gov/casestatus/logon.do
  9. // @match        https://egov.uscis.gov/casestatus/portfolioCustomerRetrieve.do
  10. // @match        https://my.uscis.gov/account/applicant
  11. // @grant        none
  12. // ==/UserScript==
  13.  
  14. window._settings = {
  15.     // user & pass can be left blank - write
  16.     // them and press submit button manually
  17.     username: "john_doe_88",
  18.     password: "secret123",
  19.    
  20.     // exactly as they appear in the egov.uscis.gov column "LAST UPDATED (MM/DD/YYYY)"
  21.     egov_dates: "04/20/2018;04/20/2018;05/22/2018",
  22.  
  23.     // as they appear on my.uscis.gov
  24.     my_statuses: [
  25.         "May 25, 2018",
  26.         "We reviewed your biometrics and are still processing your case",
  27.  
  28.         "April 20, 2018",
  29.         "We received your case",
  30.  
  31.         "May 25, 2018",
  32.         "We reviewed your biometrics and are still processing your case"
  33.     ]
  34. }
  35.  
  36.  
  37. function show_my_uscis_stuff () {
  38.     $("h3.inline-block").not(":nth(0)").click();
  39.  
  40.     var $dates = $("p.panel-pre-title");
  41.     var $titles = $("h2.panel-title");
  42.  
  43.     var announcement = false;
  44.  
  45.     for (var i = 0; i < _settings.my_statuses.length / 2; i++) {
  46.         var date = _settings.my_statuses[i * 2];
  47.         var title = _settings.my_statuses[i * 2 + 1];
  48.  
  49.         var currDate = $dates.eq(i).text();
  50.         var currTitle = $titles.eq(i).text();
  51.  
  52.         currStatuses[i * 2] = currDate;
  53.         currStatuses[i * 2 + 1] = currTitle;
  54.  
  55.         if (date.trim().toLowerCase() !=  currDate.trim().toLowerCase() ||
  56.            title.trim().toLowerCase() != currTitle.trim().toLowerCase()) {
  57.  
  58.             announcement = "⚠️⚠️⚠️ UPDATED ⚠️⚠️⚠️<br><br>" + currDate + "<br>" + currTitle;
  59.         }
  60.     }
  61.  
  62.     var theCss = {
  63.         "color": "red",
  64.         "fontFamily": "impact",
  65.         "fontSize": "4em",
  66.         "lineHeight": "1em"
  67.     };
  68.  
  69.     if (!announcement) {
  70.         announcement = "Nothing changed";
  71.         theCss.color = "green";
  72.     } else {
  73.         var toPrint = "my_statuses: [\n";
  74.         for (var i = 0; i < currStatuses.length; i++) {
  75.             toPrint += '\t"' + currStatuses[i] + '"';
  76.             if (i < currStatuses.length - 1) {
  77.                 toPrint += ",";
  78.                 if (i % 2 == 1)
  79.                     toPrint += "\n";
  80.             }
  81.             toPrint += "\n";
  82.         }
  83.         toPrint += '];';
  84.         console.log(toPrint);
  85.     }
  86.  
  87.     $(".uscis-card-content.home-banner-container h2")
  88.         .css(theCss)
  89.         .html(announcement);
  90. }
  91.  
  92. function plz_wait () {
  93.     if ($("h2.panel-title").length == 3)
  94.         show_my_uscis_stuff();
  95.     else
  96.         setTimeout(plz_wait, 100);
  97. }
  98.  
  99. (function() {
  100.  
  101.     var loc = window.location.href
  102.  
  103.     // egov.uscis.gov login page
  104.     if (!!loc.match(/egov\.uscis.*[lL]ogon.*/)) {
  105.  
  106.         var $myCases = $(".top-link-right a")
  107.         if ($myCases.length > 0 && !!$myCases.prop("href").match(/\/casestatus\/portfolioCustomerRetrieve\.do/)) {
  108.             $myCases.get(0).click()
  109.         } else if ($("#username, #password, #loginBtn").length == 3) {
  110.             if (_settings.username && _settings.password) {
  111.                 $("#username").val(_settings.username)
  112.                 $("#password").val(_settings.password)
  113.                 $("#loginBtn").click()
  114.             }
  115.         }
  116.  
  117.     // egov.uscis.gov case list (the SIMPLE one)
  118.     } else if (!!loc.match(/egov\.uscis.*portfolioCustomerRetrieve.*/)) {
  119.  
  120.         var dates = $("tr td.textalign-center:nth-child(3) nobr").text().trim().replace(/\s+/g, ";");
  121.         console.log(dates);
  122.  
  123.         var same = (dates == _settings.egov_dates);
  124.  
  125.         $(".logo-sec").remove();
  126.         $(".rows.text-center h2").css({"color":(same?"green":"red"),"font-family":"impact"})
  127.             .text(same?"Nothing changed":"⚠️ ⚠️ UPDATED ⚠️ ⚠️");
  128.  
  129.  
  130.     // my.uscis.gov case list (the longer one)
  131.     } else if (!!loc.match(/my.uscis.gov\/account\/applicant.*/)) {
  132.  
  133.         window.currStatuses = [];
  134.         plz_wait();
  135.     }
  136. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement