This repository was archived by the owner on Jun 3, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChecker.js
More file actions
159 lines (137 loc) · 4.8 KB
/
Copy pathChecker.js
File metadata and controls
159 lines (137 loc) · 4.8 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//UCF Decision Check
//Written by Jacob Kanfer
function delay(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time)
})
}
async function OCR(path){
const Tesseract = require('tesseract.js')
const cv = require('opencv4nodejs')
cv.readImage(path, function(err, im) {
if (err) throw err;
im.image = im.image.gaussianBlur(new cv.Size(5, 5), 1.2);
im.image = im.image.cvtColor(cv.COLOR_BGR2GRAY);
im.save('./out.jpg');
})
return Tesseract.recognize('./out.jpg', {lang:'eng'})
}
function textMeDecision(content){
var request = require('request')
//Defines TextBelt variables
var userPhoneNumber = '' //Enter phone number to send admission status too
var textBeltAPIKey = '' //Enter api key
//Sends post request to send text message
request.post('https://textbelt.com/text', {
form: {
phone: userPhoneNumber,
message: content,
key: textBeltAPIKey,
},
}, function(err, httpResponse, body) {
if (err) {
console.error('Error:', err)
return
}
console.log(JSON.parse(body))
})
}
function checkDecisionText(decisionText){
//Checks if accepted, waitlisted, denied, or not received yet
if (decisionText.match(/congratulations/i)){
textMeDecision('Congratulations!! You have been accepted to UCF')
decisionReceived = true
}
else if (decisionText.match(/waitlist/i)) {
textMeDecision('You have been placed on the waitlist for UCF')
decisionReceived = true
}
else if(decisionText.match(/denied/i)){
textMeDecision('You have been denied by UCF')
decisionReceived = true
}
else{
textMeDecision('Decision Not Out Yet')
decisionReceived = false
}
return decisionReceived
}
async function CheckDecision(puppeteer, i, browser){
//Loads browser in headless mode (Path set for MacOS)
var browser = await puppeteer.launch({ headless: true, executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', slowMo: '10'})
//Creates incognito browser instance
const newContext = await browser.createIncognitoBrowserContext()
//Defines UCF Login
var username = '' //Enter UCF username
var password = '' //Enter UCF password
//Launches new chrome tab
const page = await browser.newPage()
await page.setViewport({width:1200, height:814});
//Launches UCF main page
await page.goto('https://www.ucf.edu/')
//Clicks on sign in element
await page.evaluate(() => {
document.querySelector('#ucfhb-signon-logo').click()
document.querySelector('#ucfhb-myucf').click()
})
//Loops if not logged in
while (true){
//Types in UCF Username
await page.waitForSelector('.panel #username')
await page.click('#username')
await page.type('#username', username)
//Types in UCF password
await page.keyboard.press('Tab')
await page.type('#password', password)
//Clicks login Button
await page.keyboard.press('Enter')
//Enables request interception
await page.setRequestInterception(true)
page.on('request', request => {
//Checks if navigation is requested
if (!request.isNavigationRequest()) {
request.continue()
return
}
//Adds refer header for login redirect
const headers = request.headers()
headers['referer'] = 'https://idp-prod.cc.ucf.edu/idp/profile/SAML2/Redirect/SSO?execution=e2s1'
request.continue({ headers })
})
//Checks if login was successful
await page.waitForNavigation()
const title = await page.title()
if (title!=='UCF Federated Identity'){
break
}
}
//Opens Admission Status Page
await page.goto('https://my.ucf.edu/psp/IHPROD/EMPLOYEE/CSPROD/c/CF_ADM_CUSTOM.CF_HA_UGRD_APPSTAT.GBL?FolderPath=PORTAL_ROOT_OBJECT.FX_STUDENT_SLFSRV_MENU_90.FX_HE90_UNDERGRAD.FX90_UGRD_APPSTATUS&IsFolder=false&IgnoreParamTempl=FolderPath%2cIsFolder')
//Screenshots decision
const path = './Decision.jpg'
await page.screenshot({ path: path, type: 'jpeg', clip: { x: 180, y: 140, width: 700, height: 250} })
//Closes the browser
browser.close()
//Uses OCR to get decision text
var rawOCRtext = await OCR(path)
//Checks the decision text for status
var decisionReceived = checkDecisionText(Object.values(rawOCRtext)[0])
//Returns if the decision was received or not
return decisionReceived
}
(async () => {
//Defines puppeteer params
const puppeteer = require('puppeteer-extra')
const devices = require('puppeteer/DeviceDescriptors')
const pluginStealth = require('puppeteer-extra-plugin-stealth')
puppeteer.use(pluginStealth())
//Loop to run every 12 hours to check for decision status if not already recieved
var decisionReceived=false
var i = 1
while(decisionReceived!==true){
var browser = browser + i.toString()
var decisionReceived = await CheckDecision(puppeteer, i, browser)
i++
delay(43200000)
}
})()