AppleScript C Perl Shell Xcode Other

Getting current balance on your Chase Credit Card daily

Post Reply
coding / applescript     Views: 1315Prev .. Next
Getting current balance on your Chase Credit Card dailyPosted: Sunday, May 18, 2014 [20:40:40] - 1
rootPosted by:rootMember Since:
June 16 2010
Posts: 356
Being able to see your Chase Credit Card daily balances without manually checking Chase website is one of the benefits your Mac may offer.
It checks my balances by the end of the day and reports to the small data folder to display it at anytime on any of house Macs and TVs. It could be accessed over the Internet from anywhere if your router's port forwarding is setup properly.
Simple AppleScript checks Chase.com website at pre-set time (and re-checks every hour until data updated successfully):
View Code-- This AppleScript check Chase.com website for current Credit Card balance
-- AppleScript also automatically verifies the "Unrecognized Computer" VIA email
tell application "Safari" to activate
delay 3
tell application "Safari"
make new document
tell application "System Events"
tell process "Safari"
keystroke "l" using {command down}
delay 1
keystroke "https://chaseonline.chase.com/"
delay 1
keystroke return
end tell
end tell
delay 1
set web_page_is_loaded to false
set myCounter to 0
set maxCounter to 30
set my_delay to 1
repeat until web_page_is_loaded is true
if name of window 1 contains "Loading" or name of window 1 contains "Untitled" then
delay my_delay
else
set web_page_is_loaded to true
end if
set myCounter to myCounter + 1
if myCounter is maxCounter then
set web_page_is_loaded to true
end if
end repeat
delay 10
end tell

tell application "Safari"
do "document.getElementById('UserID').focus()" in document 1
tell application "System Events"
tell process "Safari"
delay 1
keystroke "Your_Username"
delay 1
keystroke tab
delay 1
keystroke "Your_Password"
delay 1
keystroke return
delay 1
end tell
end tell
delay 15
set web_page_is_loaded to false
set myCounter to 0
set maxCounter to 30
set my_delay to 1
repeat until web_page_is_loaded is true
if name of window 1 contains "Loading" or name of window 1 contains "Untitled" then
delay my_delay
else
set web_page_is_loaded to true
end if
set myCounter to myCounter + 1
if myCounter is maxCounter then
set web_page_is_loaded to true
end if
end repeat
delay 3
end tell

set logdoreport to "login"

tell application "System Events"
tell process "Safari"
keystroke "a" using {command down}
delay 1
keystroke "c" using {command down}
delay 1
set page_text to (the clipboard) as text
-- now check weather actual page contains account data or chase.com would not recognize your computer
set logdoreport to do shell script ("echo " & quoted form of page_text & " | perl /Folder_with_your_perl_program/read.chase.login.cgi")
delay 3
end tell
end tell

if logdoreport contains "verify" then -- if chase.com wants to verify your computer
set report to "empty"
tell application "Safari"
do "document.getElementById('NextButton').focus()" in document 1 -- click on Next button
end tell
tell application "System Events"
tell process "Safari"
delay 1
key code 49
delay 5
end tell
end tell
delay 3
tell application "Safari"
do "document.getElementById('usrCtrlOtp_rdoDelMethod1').focus()" in document 1 -- select "Email the code"
end tell
tell application "System Events"
tell process "Safari"
delay 1
key code 49 -- hit the "Spacebar" keyboard key - it selects the "Radio" button
delay 1
end tell
end tell
tell application "Safari"
do "document.getElementById('NextButton').focus()" in document 1 -- focus on Next button
end tell
tell application "System Events"
tell process "Safari"
delay 1
key code 49 -- hit the "Spacebar" keyboard key
delay 1
end tell
end tell
delay 15
-- Email being sent to email account associated with your Chase.com account
-- Now, fire your Mail program and read the code sent from Chase.com
tell application "Mail"
delay 1
activate
delay 5
check for new mail
delay 15 -- delay allows for email to be properly collected and downloaded
-- if Mail was active delay 5 would be more appropriate
-- in this particular case program checks Gmail account
-- to properly select account use email Account Description from Mail Preferences -> Accounts, not email address
-- check for new unread messages in INBOX
set unreadMessages to (get every message of mailbox "INBOX" of account "Gmail" whose read status is false)
repeat with eachMessage in unreadMessages
if subject of eachMessage contains "Requested Online Banking Identification" then -- match new email from Chase by Subject
set readcont to content of eachMessage
-- feed the message to Perl to get the code: report variable gets the code
set report to do shell script ("echo " & quoted form of readcont & " | perl /Folder_with_your_perl_program/read.chase.code.cgi")
exit repeat
end if
end repeat
end tell -- end mail check
delay 1
tell application "Mail" to quit -- comment it if you do not need to quit Mail
delay 5
if report does not contain "bad number" then -- if good code received by email
tell application "Safari"
-- focus on Code text input field
do "document.getElementById('usrCtrlOtp_txtActivationCode').focus()" in document 1
end tell
tell application "System Events"
tell process "Safari"
delay 1
-- enter the code sent by Chase.com
keystroke report
delay 1
-- now go to Account Password field
keystroke tab
delay 1
keystroke tab
delay 1
keystroke "Your_Password" -- enter your Account Password
delay 1
keystroke return -- hit Submit
delay 10 -- wait for page to load
end tell
end tell
delay 5
end if -- end if good code received by email
end if -- end if chase.com wants to verify your computer

tell application "Safari"
set LinkPresent to ""
set AllLinks to ""
set TransMatched to ""
set exitNmbr to 5
set LinkPresent to (do "document.links.length" in document 1)
set LinkPresent to LinkPresent - 1
set Split to ""
-- now, iterate through links on the page
repeat with n from 0 to LinkPresent
set linkURL to (do "document.links[" & n & "].href" in document 1)
set linkName to (do "document.links[" & n & "].text" in document 1)
if linkName contains "See more information" then
-- Account_Code is unique code for your Credit Card Account provided by Chase, usually numbers
if linkURL contains "Account_Code" then
do "document.links[" & n & "].focus();" in document 1
delay 1
set LinkPresent to n
exit repeat
end if
end if -- TRANSFER TO BANK ACCOUNT LINK END
end repeat

tell application "System Events"
tell process "Safari"
keystroke return
end tell
end tell

delay 5

set web_page_is_loaded to false
set myCounter to 0
set maxCounter to 30
set my_delay to 1
repeat until web_page_is_loaded is true
if name of window 1 contains "Loading" or name of window 1 contains "Untitled" then
delay my_delay
else
set web_page_is_loaded to true
end if
set myCounter to myCounter + 1
if myCounter is maxCounter then
set web_page_is_loaded to true
end if
end repeat
delay 3

-- now we're on your Credit Card current info page - gather data and pass it to perl for logging
tell application "System Events"
tell process "Safari"
keystroke "a" using {command down}
delay 1
keystroke "c" using {command down}
delay 1
set page_text to (the clipboard) as text
do shell script ("echo " & quoted form of page_text & " | perl /Folder_with_your_perl_program/store.chase.data.cgi")
delay 3
-- next either close Safari window or quit Safari completely
keystroke "w" using {command down} -- close Safari window
--keystroke "q" using {command down} -- quit Safari
end tell
end tell
end tell

Save this AppleScript as an .app and run it from cron, daemon or manually.
It is probably not the most sophisticated program in the World but it simplifies my life to the point where I have my account balance handy.
Perl scripts to work with AppleScript coming-up next.There's no place like ~
RE: Getting current balance on your Chase Credit Card dailyPosted: Sunday, May 18, 2014 [21:00:48] - 2
rootPosted by:rootMember Since:
June 16 2010
Posts: 356
This Perl script checks if after entering your credentials AppleScript got to the Account Page or further verification required - /Folder_with_your_perl_program/read.chase.login.cgi
View Code#!/usr/bin/perl
unless($ENV{'SECURITYSESSIONID'}) {
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local:/usr/local/bin';
}
$vr = <STDIN>; ## GET DATA
$vr =~ s/\012?\015/\n/gi;$vr =~ s/\012/\n/g;

if($vr =~ m/When we don\'t recognize the computer/i) {print "do verify";} else {print "login";}


Next, read email and find the code sent by Chase /Folder_with_your_perl_program/read.chase.code.cgi
View Code#!/usr/bin/perl
unless($ENV{'SECURITYSESSIONID'}) {
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local:/usr/local/bin';
}
while(<STDIN>) {$d .= $_;} ## READ THE INPUT
$d =~ s/^\s*{.*\n//g; # remove lines starting with braces
$d =~ s/\\[\w-]+\b//g; # remove RTF commands
$d =~ s/(\n)\s+(\S+)/$1$2/g; # remove extra spaces
$d =~ s/([^\\\n]+)\\(\n)/$1$2/g; # get rid of \ at the ends of lines
$d =~ s/\\\n//g; # get rid of lines with a \ only

$d =~ s/\012?\015/\n/gi;$d =~ s/\012/\n/g;
$d =~ s/(.)/(ord($1) > 127) ? "" : $1/egs;$d =~ s/\r/\t/g;$d =~ s/\n|\s/\t/g;$d =~ tr/\t\t//s;
$d =~ s#(.*?)(Your\tIdentification\tCode\tis\:)(\t)(\d{8})(\s)(\w+|\W)#$4#ie;

if($d =~ m/ /) {($d,$sh) = split(/ /,$d);}
elsif($d =~ m/\t/) {($d,$sh) = split(/\t/,$d);}
else {$d =~ s/(\d{8}\b)(.*?)/$1/;}

$d =~ s/\D//g;
if(length($d) > 7 && length($d) < 10) {print "$d";} else {print "bad number";}
exit(0);


and now, collect and write data file for Credit Card balances /Folder_with_your_perl_program/store.chase.data.cgi

View Code#!/usr/bin/perl
unless($ENV{'SECURITYSESSIONID'}) {
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local:/usr/local/bin';
}
$vr = <STDIN>;
$vr =~ s/\012?\015/\n/gi;$vr =~ s/\012/\n/g;
if(length($vr) > 10) {
open(TXT,">/temp/last.chase.txt");print TXT $vr;close(TXT);
} ## END VR PRESENT
$vr='';

if(-f "/temp/last.chase.txt") {
$d = `cat /temp/last.chase.txt`;
($sh,$d) = split(/Details for CREDIT CARD/,$d);
($d,$sh) = split(/BLUEPRINT/,$d);
$d =~ s#\((.*?)\)##g;
$d =~ s#(\d{1,2})\,(\d{3})(\.)(\d{2})#$1$2$3$4#g;
$d =~ s/\r//g;$d =~ tr/\n\n//s;$d =~ s/^\s+//;$d =~ s/\s+$//;$d =~ tr/\n\n//s;
@all=split(/\n/,$d);$d='';
foreach $l (@all) {
$l =~ s/^\t+//;$l =~ s/^\s+//;
unless(length($l) > 2) {next;}
unless($l =~ m/\t/) {$header = $l;next;}
@altabs = split(/\t/,$l);$key=shift(@altabs);$val = pop(@altabs);@altabs=();
$header =~ s#As of \d{1,2}/\d{1,2}/\d{4}##i;$header =~ s/\s+$//;
$read{$header}{$key}=$val;
} ## FOREACH LINE END

foreach $hd (sort keys(%read)) {
$totbl .= "<tr><th colspan=2>$hd</th></tr>\n";
foreach $key (sort keys %{$read{$hd}}) {$read{$hd}{$key} =~ s#\b(\d{1,2})(\d{3})(\.)(\d{2})#$1\,$2$3$4#;
$totbl .= "<tr><td>$key</td><td>$read{$hd}{$key}</td></tr>\n";
} ## FOREACH KEY END
} ## FOREACH HEAD END

$tdate=time;
my $finaltime = localtime($tdate);$finaltime =~ tr/ //s;
open(TXT,">/data_files/chase.data.txt");
print TXT <<EOH;
Chase Freedom<a href="#" onclick="showhide('chaseslate')">: $read{'Account Info'}{'Available Credit'}</a>
<div id="chaseslate" style="display:none;"><table border=\"0\" class=\"ktbl\">\n<tr><th colspan=2>Collected: $finaltime</th></tr>
$totbl</table></div>
EOH
close(TXT);
} ## END LAST CHASE PRESENT
close(TXL);

unless($read{'Account Info'}{'Available Credit'} =~ m/\d/) {
if(-f "/data_files/chase.data.txt") {unlink "/data_files/chase.data.txt";}
}

sub num {$a <=> $b;}
There's no place like ~
coding / applescriptPrev .. Next
 
Post Reply
Home - Coding: AppleScript C Perl Shell Xcode Other
Our Telegram Group