-
Notifications
You must be signed in to change notification settings - Fork 121
/
MintGetAccountBalances.ahk
66 lines (53 loc) · 2.08 KB
/
MintGetAccountBalances.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include FcnLib.ahk
#include FcnLib-Nightly.ahk
MintLogIn()
mintPage := iMacroUrlDownloadToVar("https://wwws.mint.com/overview.event")
;AddToTrace(mintPage)
;mintPage:=FileRead(GetPath("trace"))
ini=C:\Dropbox\AHKs\gitExempt\mintIDs.ini
keylist := IniListAllKeys(ini, "default")
Loop, parse, keylist, CSV
GrabDataFromPage(mintPage, A_LoopField)
ExitApp
GetRegEx(tag, contents="")
{
none=[^<>]*
if contents
returned=<%none%%tag%%none%>((%none%%contents%%none%)</%none%>)
else
returned=<%none%%tag%%none%>((%none%)</%none%>)?
return returned
}
GrabDataFromPage(page, id)
{
none=[^<>]*
oneXML=<%none%>
smallXML=<[^<>]{0,3}>
smallOrNone=(%smallXML%|%none%)*
;balanceRE:=GetRegEx("balance")
;accountRE:=GetRegEx("accountName")
;updatedRE:=GetRegEx("last-updated")
;nicknameRE:=GetRegEx("nickname")
accountIdRE:=GetRegEx("accountId=" . id) . smallOrNone
imageRE:=GetRegEx("img") . smallOrNone
balanceRE:=GetRegEx("balance") . smallOrNone
accountRE:=GetRegEx("accountName") . smallOrNone
updatedRE:=GetRegEx("last-updated") . smallOrNone
nicknameRE:=GetRegEx("nickname") . smallOrNone
regex=(?P<id>%accountIdRE%)%imageRE%(?P<balance>%balanceRE%)%accountRE%(?P<updated>%updatedRE%)(?P<nickname>%nicknameRE%)
;regex=last-updated.*?(second|minute|hour|day|week).*?FOUR STAR CHECKING.*?balance...([0-9,.]+)
;TODO don't update the numbers if the last updated date is old
if NOT RegExMatch(page, regex, match)
return
ini=C:\Dropbox\AHKs\gitExempt\mintIDs.ini
balance := StringReplace(match9, "$")
balance := StringReplace(balance, ",")
balance := StringReplace(balance, "–", "-") ;replace the stylish emdash with normal minus
balance := RegExReplace(balance, oneXML)
balance := RegExReplace(balance, "[^0-9.]{3}", "-") ;replace the stylish emdash with normal minus
nickname := IniRead(ini, default, id)
if NOT RegExMatch(id, "^527155")
nickname .= "zzz" . id
;debug(matchid, nickname, balance)
NightlyStats(nickname, balance, "noemail")
}